-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.modern.js
54 lines (53 loc) · 1.08 KB
/
webpack.modern.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
const path = require('path');
const childProcess = require('child_process');
const branchName = childProcess.execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
module.exports = merge(common, {
mode: 'production',
entry: './src/index.js',
output: {
filename: 'bundle.js',
chunkFilename: 'bundle.chunk.[fullhash:8].[id].js',
chunkLoadingGlobal: `${branchName}BundleChunks`,
},
target: 'browserslist:modern',
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
browserslistEnv: 'modern',
},
],
],
},
},
},
],
},
devServer: {
client: false,
server: 'https',
port: 3333,
hot: false,
allowedHosts: 'all',
headers: {
'Access-Control-Allow-Origin': '*',
},
static: {
directory: path.join(__dirname, 'public'),
publicPath: ['/'],
watch: false,
},
devMiddleware: {
publicPath: '/dist/',
},
},
});