Hello,
Before Webix 6.0 (webix 5.7 webix jet 1.0), anlike zzm3145, I’was used to have two entries in webpack.config (the main app.js and an array of the path to licensed libraries as webix pro) in order to obtain two separated js files (and css too). In this way, my index.html could keep having two script entries (as Webix support recommends), one for licensed libraries and one for the webix-jet app.
Now I’m trying to update webpack.config.js and package.json to use webpack 4 and the last releases of webix and jet. However, although I obtain the code splitted into two js files, I get the error in js console “Can’t find variable: webix”.
Can you help me, please?
This is my webpack.config.js:
var path = require("path");
var webpack = require("webpack");
module.exports = function(env) {
var pack = require("./package.json");
var MiniCssExtractPlugin = require("mini-css-extract-plugin");
var production = !!(env && env.production === "true");
var asmodule = !!(env && env.module === "true");
var standalone = !!(env && env.standalone === "true");
var babelSettings = {
extends: path.join(__dirname, '/.babelrc')
};
//Vendors paths
const vendors_path = path.resolve(__dirname,"./sources/external_libs/vendors/");
//
const vendors_paths = [
path.join(vendors_path, "/webix/webix.min.js"),
path.join(vendors_path, "/webix/skins/" + `${pack.skin}` + ".min.css"),
//
//path.join(vendors_path, "/webix-filemanager/filemanager.min.js"),
//path.join(vendors_path, "/webix-filemanager/filemanager.min.css"),
];
//Output path
var publicPath = "/dist/";
if (production) {
publicPath = "../dist/";
}
var config = {
mode: production ? "production" : "development",
entry: {
deps: vendors_paths,
app: "./sources/app.js"
},
output: {
path: path.join(__dirname, "dist"),
publicPath: publicPath,
filename: "[name].js",
chunkFilename: "[name].bundle.js"
},
module: {
rules: [
{
test: /\\.js$/,
use: "babel-loader?" //+ JSON.stringify(babelSettings)
},
{
test: /\\.(svg|png|jpg|gif)$/,
use: "url-loader?limit=25000&name=imgs/[name].[ext]"
},
{
test: /\\.(svg|eot|ttf|woff|woff2)$/,
loader: 'file-loader',
options: {
name: "fonts/[name].[ext]",
//useRelativePath: process.env.NODE_ENV === "production"
}
},
{
test: /\\.(less|css)$/,
use: [ MiniCssExtractPlugin.loader, "css-loader", "less-loader" ]
}
]
},
stats:"minimal",
resolve: {
extensions: [".js"],
modules: ["./sources", "node_modules"],
alias:{
"jet-views":path.resolve(__dirname, "sources/views"),
"jet-locales":path.resolve(__dirname, "sources/locales")
}
},
plugins: [
new MiniCssExtractPlugin({
filename:"[name].css"
}),
new webpack.DefinePlugin({
VERSION: `"${pack.version}"`,
APPNAME: `"${pack.name}"`,
PRODUCTION : production,
BUILD_AS_MODULE : (asmodule || standalone)
})
],
devServer:{
stats:"errors-only",
// proxy:{
// "/server" : "http://localhost:8888/webix-jet-start-php/"
// }
},
// optimization: {
// splitChunks: {
// cacheGroups: {
// vendors: {
// test: /[\\\\/]vendors[\\\\/]/,/// + vendors_path + /,
// name: 'deps',
// //chunks: 'all'
// },
// default: {
// test: /^([\\\\/]vendors[\\\\/])/,
// name: 'app',
// //chunks: 'all'
// },
// }
// }
// }
};
if (!production){
config.devtool = "inline-source-map";
} else {
config.devtool = "source-map";
}
if (asmodule){
if (!standalone){
config.externals = config.externals || {};
config.externals = [ "webix-jet" ];
}
const out = config.output;
out.library = pack.name.replace(/[^a-z0-9]/gi, "");
out.libraryTarget= "umd";
}
return config;
}