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 minimumApp: ["./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"
65 namedModules: env !== "release",
66 minimize: env === "release",
67 minimizer: env !== "release" ? [] : [new TerserPlugin({
69 warnings: false, // false, true, "verbose"
79 new webpack.DllReferencePlugin({
80 context: path.resolve(__dirname, "../../framework/src"),
81 manifest: require(path.resolve(frameworkPath, "vendor-manifest.json")),
84 new webpack.DllReferencePlugin({
85 context: path.resolve(__dirname, "../../framework/src"),
86 manifest: require(path.resolve(frameworkPath, "app-manifest.json")),
89 ...(env === "release" ? [
90 new webpack.DefinePlugin({
92 NODE_ENV: "'production'",
93 VERSION: JSON.stringify(require("./package.json").version)
97 new webpack.DefinePlugin({
99 NODE_ENV: "'development'",
100 VERSION: JSON.stringify(require("./package.json").version)
103 new CopyWebpackPlugin([{
111 public: "http://localhost:3100",
112 contentBase: frameworkPath,
116 "Access-Control-Allow-Origin": "*"
120 disableHostCheck: true,
121 historyApiFallback: true,
130 target: "http://localhost:3001",