2 * Webpack 4 configuration file
3 * see https://webpack.js.org/configuration/
4 * see https://webpack.js.org/configuration/dev-server/
9 const path = require("path");
10 const webpack = require("webpack");
11 const CopyWebpackPlugin = require("copy-webpack-plugin");
12 const TerserPlugin = require('terser-webpack-plugin');
14 // const __dirname = (path => path.replace(/^([a-z]\:)/, c => c.toUpperCase()))(process.__dirname());
16 module.exports = (env) => {
17 const distPath = path.resolve(__dirname, env === "release" ? "." : "../..", "dist");
18 const frameworkPath = path.resolve(__dirname, env === "release" ? "../../framework" : "../..", "dist");
22 mode: "none", //disable default behavior
26 context: path.resolve(__dirname, "src"),
29 apiDemo: ["./plugin.tsx"]
32 devtool: env === "release" ? false : "source-map",
35 extensions: [".ts", ".tsx", ".js", ".jsx"]
40 filename: "[name].js",
42 libraryTarget: "umd2",
43 chunkFilename: "[name].js"
48 exclude: /node_modules/,
50 loader: "babel-loader"
56 exclude: /node_modules/,
58 loader: "babel-loader"
64 namedModules: env !== "release",
65 minimize: env === "release",
66 minimizer: env !== "release" ? [] : [new TerserPlugin({
68 warnings: false, // false, true, "verbose"
77 // new CopyWebpackPlugin([{
78 // from: '../../../dist/**.*',
79 // to: path.resolve(__dirname, "dist")
81 new webpack.DllReferencePlugin({
82 context: path.resolve(__dirname, "../../framework/src"),
83 manifest: require(path.resolve(frameworkPath, "vendor-manifest.json")),
86 new webpack.DllReferencePlugin({
87 context: path.resolve(__dirname, "../../framework/src"),
88 manifest: require(path.resolve(frameworkPath, "app-manifest.json")),
91 ...(env === "release" ? [
92 new webpack.DefinePlugin({
94 NODE_ENV: "'production'",
95 VERSION: JSON.stringify(require("./package.json").version)
99 new webpack.DefinePlugin({
101 NODE_ENV: "'development'",
102 VERSION: JSON.stringify(require("./package.json").version)
105 new CopyWebpackPlugin([{
113 public: "http://localhost:3100",
114 contentBase: frameworkPath,
118 "Access-Control-Allow-Origin": "*"
122 disableHostCheck: true,
123 historyApiFallback: true,
132 target: "https://dlux.just-run.it",