|
1 |
| -const path = require("path"); |
2 |
| -const mode = process.env.NODE_ENV || "production"; |
3 |
| -const BundleAnalyzerPlugin = require("webpack-bundle-analyzer") |
4 |
| - .BundleAnalyzerPlugin; |
| 1 | +const path = require( 'path' ); |
| 2 | +const mode = process.env.NODE_ENV || 'production'; |
| 3 | +const BundleAnalyzerPlugin = require( 'webpack-bundle-analyzer' ) |
| 4 | + .BundleAnalyzerPlugin; |
5 | 5 |
|
6 | 6 | const sharedConfig = {
|
7 |
| - mode: mode, |
8 |
| - entry: { |
9 |
| - analytics: path.resolve(__dirname, "src/analytics.js"), |
10 |
| - }, |
11 |
| - output: { |
12 |
| - path: path.resolve(__dirname, "build"), |
13 |
| - filename: "[name].js", |
14 |
| - publicPath: ".", |
15 |
| - libraryTarget: "this", |
16 |
| - jsonpFunction: "HManalyticsJSONP", |
17 |
| - }, |
18 |
| - module: { |
19 |
| - rules: [ |
20 |
| - { |
21 |
| - test: /\.m?js$/, |
22 |
| - exclude: /(node_modules|bower_components)/, |
23 |
| - use: { |
24 |
| - loader: "babel-loader", |
25 |
| - options: { |
26 |
| - presets: [ |
27 |
| - require("@babel/preset-env"), |
28 |
| - require("@babel/preset-react"), |
29 |
| - ], |
30 |
| - plugins: [ |
31 |
| - require("@babel/plugin-transform-runtime"), |
32 |
| - require('@wordpress/babel-plugin-import-jsx-pragma'), |
33 |
| - ], |
34 |
| - }, |
35 |
| - }, |
36 |
| - }, |
37 |
| - ], |
38 |
| - }, |
39 |
| - optimization: { |
40 |
| - noEmitOnErrors: true, |
41 |
| - }, |
42 |
| - plugins: [], |
43 |
| - devtool: |
44 |
| - mode === "production" |
45 |
| - ? "cheap-module-source-map" |
46 |
| - : "cheap-module-eval-source-map", |
47 |
| - externals: { |
48 |
| - "Altis": "Altis", |
49 |
| - "wp": "wp", |
50 |
| - "react": "React", |
51 |
| - "react-dom": "ReactDOM", |
52 |
| - }, |
| 7 | + mode: mode, |
| 8 | + entry: { |
| 9 | + analytics: path.resolve( __dirname, 'src/analytics.js' ), |
| 10 | + }, |
| 11 | + output: { |
| 12 | + path: path.resolve( __dirname, 'build' ), |
| 13 | + filename: '[name].js', |
| 14 | + publicPath: '.', |
| 15 | + libraryTarget: 'this', |
| 16 | + jsonpFunction: 'HManalyticsJSONP', |
| 17 | + }, |
| 18 | + module: { |
| 19 | + rules: [ |
| 20 | + { |
| 21 | + test: /\.m?js$/, |
| 22 | + exclude: /(node_modules|bower_components)/, |
| 23 | + use: { |
| 24 | + loader: 'babel-loader', |
| 25 | + options: { |
| 26 | + presets: [ |
| 27 | + require( '@babel/preset-env' ), |
| 28 | + require( '@babel/preset-react' ), |
| 29 | + ], |
| 30 | + plugins: [ |
| 31 | + require( '@babel/plugin-transform-runtime' ), |
| 32 | + require( '@wordpress/babel-plugin-import-jsx-pragma' ), |
| 33 | + ], |
| 34 | + }, |
| 35 | + }, |
| 36 | + }, |
| 37 | + ], |
| 38 | + }, |
| 39 | + optimization: { |
| 40 | + noEmitOnErrors: true, |
| 41 | + }, |
| 42 | + plugins: [], |
| 43 | + devtool: ( |
| 44 | + mode === 'production' |
| 45 | + ? 'cheap-module-source-map' |
| 46 | + : 'cheap-module-eval-source-map' |
| 47 | + ), |
| 48 | + externals: { |
| 49 | + 'Altis': 'Altis', |
| 50 | + 'wp': 'wp', |
| 51 | + 'react': 'React', |
| 52 | + 'react-dom': 'ReactDOM', |
| 53 | + }, |
53 | 54 | };
|
54 | 55 |
|
55 |
| -if (process.env.ANALYSE_BUNDLE) { |
56 |
| - // Add bundle analyser. |
57 |
| - sharedConfig.plugins.push(new BundleAnalyzerPlugin()); |
| 56 | +if ( process.env.ANALYSE_BUNDLE ) { |
| 57 | + // Add bundle analyser. |
| 58 | + sharedConfig.plugins.push( new BundleAnalyzerPlugin() ); |
58 | 59 | }
|
59 | 60 |
|
60 | 61 | module.exports = sharedConfig;
|
0 commit comments