|
1 |
| -//plugins |
2 |
| -const { DefinePlugin } = require('webpack'); |
3 |
| -const { CleanWebpackPlugin } = require('clean-webpack-plugin'); |
4 |
| -const HtmlWebpackPlugin = require('html-webpack-plugin'); |
5 |
| -const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); |
6 |
| - |
7 |
| -//libraries |
8 |
| -const path = require('path'); |
9 |
| - |
10 |
| -//the exported config function |
11 |
| -module.exports = ({ production, analyzer }) => { |
12 |
| - |
13 |
| - return { |
14 |
| - mode: production ? "production" : "development", |
15 |
| - entry: path.resolve(__dirname, 'client', 'client.jsx'), |
16 |
| - output: { |
17 |
| - path: path.resolve(__dirname, 'public'), |
18 |
| - filename: '[name].[chunkhash].js', |
19 |
| - sourceMapFilename: '[name].[chunkhash].js.map' |
20 |
| - }, |
21 |
| - devtool: production ? 'source-map' : 'eval-source-map', |
22 |
| - resolve: { |
23 |
| - extensions: ['.js', '.jsx'] |
24 |
| - }, |
25 |
| - module: { |
26 |
| - rules: [ |
27 |
| - { |
28 |
| - test: /\.(js|jsx)$/, |
29 |
| - exclude: /(node_modules)/, |
30 |
| - use: [ |
31 |
| - { |
32 |
| - loader: 'babel-loader', |
33 |
| - options: { |
34 |
| - presets: ['@babel/preset-env', '@babel/preset-react'], |
35 |
| - plugins: ['@babel/plugin-syntax-dynamic-import'] |
36 |
| - } |
37 |
| - } |
38 |
| - ] |
39 |
| - }, |
40 |
| - { |
41 |
| - test: /\.(css)$/, |
42 |
| - use: ['style-loader', 'css-loader'] |
43 |
| - }, |
44 |
| - { |
45 |
| - test: /\.(md)$/, |
46 |
| - use: [ |
47 |
| - { |
48 |
| - loader: 'raw-loader' |
49 |
| - }, |
50 |
| - ], |
51 |
| - }, |
52 |
| - ] |
53 |
| - }, |
54 |
| - plugins: [ |
55 |
| - new DefinePlugin({ |
56 |
| - 'process.env': { |
57 |
| - 'PRODUCTION': production, |
58 |
| - 'NEWS_URI': production ? `"${process.env.NEWS_URI}"` : '"https://dev-news.eggtrainer.com"', |
59 |
| - 'AUTH_URI': production ? `"${process.env.AUTH_URI}"` : '"https://dev-auth.eggtrainer.com"', |
60 |
| - 'CHAT_URI': production ? `"${process.env.CHAT_URI}"` : '"https://dev-chat.eggtrainer.com"', |
61 |
| - } |
62 |
| - }), |
63 |
| - new CleanWebpackPlugin({ |
64 |
| - cleanOnceBeforeBuildPatterns: ['*', '!content*'] |
65 |
| - }), |
66 |
| - new HtmlWebpackPlugin({ |
67 |
| - template: './client/template.html', |
68 |
| - minify: { |
69 |
| - collapseWhitespace: production, |
70 |
| - removeComments: production, |
71 |
| - removeAttributeQuotes: production |
72 |
| - } |
73 |
| - }), |
74 |
| - new BundleAnalyzerPlugin({ |
75 |
| - analyzerMode: analyzer ? 'server' : 'disabled' |
76 |
| - }) |
77 |
| - ], |
78 |
| - devServer: { |
79 |
| - contentBase: path.resolve(__dirname, 'public'), |
80 |
| - compress: true, |
81 |
| - port: 3001, |
82 |
| - proxy: { |
83 |
| - '/api/': 'http://localhost:3000/' |
84 |
| - }, |
85 |
| - overlay: { |
86 |
| - errors: true |
87 |
| - }, |
88 |
| - stats: { |
89 |
| - colors: true, |
90 |
| - hash: false, |
91 |
| - version: false, |
92 |
| - timings: false, |
93 |
| - assets: false, |
94 |
| - chunks: false, |
95 |
| - modules: false, |
96 |
| - reasons: false, |
97 |
| - children: false, |
98 |
| - source: false, |
99 |
| - errors: true, |
100 |
| - errorDetails: false, |
101 |
| - warnings: true, |
102 |
| - publicPath: false |
103 |
| - }, |
104 |
| - host: '0.0.0.0', |
105 |
| - disableHostCheck: true, |
106 |
| - clientLogLevel: 'silent', |
107 |
| - historyApiFallback: true, |
108 |
| - hot: true, |
109 |
| - injectHot: true |
110 |
| - }, |
111 |
| - watchOptions: { |
112 |
| - ignored: /(node_modules)/ |
113 |
| - } |
114 |
| - } |
115 |
| -}; |
116 |
| - |
| 1 | +//plugins |
| 2 | +const { DefinePlugin } = require('webpack'); |
| 3 | +const { CleanWebpackPlugin } = require('clean-webpack-plugin'); |
| 4 | +const HtmlWebpackPlugin = require('html-webpack-plugin'); |
| 5 | +const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); |
| 6 | + |
| 7 | +//libraries |
| 8 | +const path = require('path'); |
| 9 | + |
| 10 | +//the exported config function |
| 11 | +module.exports = ({ production, analyzer }) => { |
| 12 | + |
| 13 | + return { |
| 14 | + mode: production ? "production" : "development", |
| 15 | + entry: path.resolve(__dirname, 'client', 'client.jsx'), |
| 16 | + output: { |
| 17 | + path: path.resolve(__dirname, 'public'), |
| 18 | + filename: '[name].[chunkhash].js', |
| 19 | + sourceMapFilename: '[name].[chunkhash].js.map' |
| 20 | + }, |
| 21 | + devtool: production ? 'source-map' : 'eval-source-map', |
| 22 | + resolve: { |
| 23 | + extensions: ['.js', '.jsx'] |
| 24 | + }, |
| 25 | + module: { |
| 26 | + rules: [ |
| 27 | + { |
| 28 | + test: /\.(js|jsx)$/, |
| 29 | + exclude: /(node_modules)/, |
| 30 | + use: [ |
| 31 | + { |
| 32 | + loader: 'babel-loader', |
| 33 | + options: { |
| 34 | + presets: ['@babel/preset-env', '@babel/preset-react'], |
| 35 | + plugins: ['@babel/plugin-syntax-dynamic-import'] |
| 36 | + } |
| 37 | + } |
| 38 | + ] |
| 39 | + }, |
| 40 | + { |
| 41 | + test: /\.(css)$/, |
| 42 | + use: ['style-loader', 'css-loader'] |
| 43 | + }, |
| 44 | + { |
| 45 | + test: /\.(md)$/, |
| 46 | + use: [ |
| 47 | + { |
| 48 | + loader: 'raw-loader' |
| 49 | + }, |
| 50 | + ], |
| 51 | + }, |
| 52 | + ] |
| 53 | + }, |
| 54 | + plugins: [ |
| 55 | + new DefinePlugin({ |
| 56 | + 'process.env': { |
| 57 | + 'PRODUCTION': production, |
| 58 | + 'NEWS_URI': production ? `"${process.env.NEWS_URI}"` : '"https://dev-news.krgamestudios.com"', |
| 59 | + 'AUTH_URI': production ? `"${process.env.AUTH_URI}"` : '"https://dev-auth.krgamestudios.com"', |
| 60 | + 'CHAT_URI': production ? `"${process.env.CHAT_URI}"` : '"https://dev-chat.krgamestudios.com"', |
| 61 | + } |
| 62 | + }), |
| 63 | + new CleanWebpackPlugin({ |
| 64 | + cleanOnceBeforeBuildPatterns: ['*', '!content*'] |
| 65 | + }), |
| 66 | + new HtmlWebpackPlugin({ |
| 67 | + template: './client/template.html', |
| 68 | + minify: { |
| 69 | + collapseWhitespace: production, |
| 70 | + removeComments: production, |
| 71 | + removeAttributeQuotes: production |
| 72 | + } |
| 73 | + }), |
| 74 | + new BundleAnalyzerPlugin({ |
| 75 | + analyzerMode: analyzer ? 'server' : 'disabled' |
| 76 | + }) |
| 77 | + ], |
| 78 | + devServer: { |
| 79 | + contentBase: path.resolve(__dirname, 'public'), |
| 80 | + compress: true, |
| 81 | + port: 3001, |
| 82 | + proxy: { |
| 83 | + '/api/': 'http://localhost:3000/' |
| 84 | + }, |
| 85 | + overlay: { |
| 86 | + errors: true |
| 87 | + }, |
| 88 | + stats: { |
| 89 | + colors: true, |
| 90 | + hash: false, |
| 91 | + version: false, |
| 92 | + timings: false, |
| 93 | + assets: false, |
| 94 | + chunks: false, |
| 95 | + modules: false, |
| 96 | + reasons: false, |
| 97 | + children: false, |
| 98 | + source: false, |
| 99 | + errors: true, |
| 100 | + errorDetails: false, |
| 101 | + warnings: true, |
| 102 | + publicPath: false |
| 103 | + }, |
| 104 | + host: '0.0.0.0', |
| 105 | + disableHostCheck: true, |
| 106 | + clientLogLevel: 'silent', |
| 107 | + historyApiFallback: true, |
| 108 | + hot: true, |
| 109 | + injectHot: true |
| 110 | + }, |
| 111 | + watchOptions: { |
| 112 | + ignored: /(node_modules)/ |
| 113 | + } |
| 114 | + } |
| 115 | +}; |
| 116 | +
|
0 commit comments