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 mediatorApp: ["./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"
62 test: /\.(png|gif|jpg|svg)$/,
67 name: './images/[name].[ext]'
75 namedModules: env !== "release",
76 minimize: env === "release",
77 minimizer: env !== "release" ? [] : [new TerserPlugin({
79 warnings: false, // false, true, "verbose"
89 new webpack.DllReferencePlugin({
90 context: path.resolve(__dirname, "../../framework/src"),
91 manifest: require(path.resolve(frameworkPath, "vendor-manifest.json")),
94 new webpack.DllReferencePlugin({
95 context: path.resolve(__dirname, "../../framework/src"),
96 manifest: require(path.resolve(frameworkPath, "app-manifest.json")),
99 ...(env === "release" ? [
100 new webpack.DefinePlugin({
102 NODE_ENV: "'production'",
103 VERSION: JSON.stringify(require("./package.json").version)
107 new webpack.DefinePlugin({
109 NODE_ENV: "'development'",
110 VERSION: JSON.stringify(require("./package.json").version)
113 new CopyWebpackPlugin([{
121 public: "http://localhost:3100",
122 contentBase: frameworkPath,
126 "Access-Control-Allow-Origin": "*"
130 disableHostCheck: true,
131 historyApiFallback: true,
140 target: "http://localhost:3000",
144 target: "http://localhost:3000",
148 target: "http://localhost:3000",
152 target: "http://localhost:3000",