This repository has been archived by the owner on Jul 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
webpack.config.test.js
89 lines (85 loc) · 2.59 KB
/
webpack.config.test.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Webpack configuration for TEST environments.
*/
const entries = require('./webpack/entries')
const config = require('./webpack/config')
const paths = require('./webpack/paths')
const shared = require('./webpack/shared')
const assetsFile = require('./webpack/plugins/assets-file')
const hashedModuleIds = require('./webpack/plugins/hashed-module-ids')
const vendorDistributionShortcut = require('./webpack/plugins/vendor-shortcut')
const distributionShortcut = require('./webpack/plugins/distribution-shortcut')
const babel = require('./webpack/rules/babel')
module.exports = {
mode: 'development',
// configure webpack logs
stats: {
colors: true,
errorDetails: true
},
// configure output files
output: {
path: paths.output(),
publicPath: '/dist',
// use content hash in the name of generated file for proper caching
filename: '[name].[contenthash].js', // this is for static entries declared in assets.json
chunkFilename: '[name].[contenthash].js' // this is for dynamic entries declared in modules/plugin.js
},
module: {
rules: [
babel()
]
},
// grab entries to compile
entry: Object.assign({},
// get the one defined in assets.json file (static entries)
entries.collectEntries(),
// get the one defined in modules/plugin.js file (dynamic entries)
{plugins: config.collectConfig()}
),
plugins: [
assetsFile('webpack-test.json'),
hashedModuleIds(),
vendorDistributionShortcut(),
distributionShortcut()
],
optimization: {
// bundle webpack runtime code into a single chunk file
// it avoids having it embed in each generated chunk
runtimeChunk: 'single',
splitChunks: {
// just use a more agnostic char for chunk names generation (default is ~)
automaticNameDelimiter: '-',
cacheGroups: {
// bundle common vendors
vendor: {
name: 'vendor',
test: /[\\/]node_modules[\\/]/,
chunks: 'all',
minChunks: 4,
priority: -10,
reuseExistingChunk: true
},
app: {
name: 'app',
test: /[\\/]vendor[\\/]claroline[\\/]distribution[\\/]main[\\/]app/,
minChunks: 4,
priority: -20,
chunks: 'all',
reuseExistingChunk: true
},
// bundle common modules to decrease generated file size
default: {
minChunks: 5,
priority: -30,
reuseExistingChunk: true
}
}
}
},
resolve: {
modules: ['./node_modules', './public/packages'],
extensions: ['.js', '.jsx']
},
externals: shared.externals()
}