-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.web.development.js
More file actions
77 lines (74 loc) · 2.01 KB
/
Copy pathwebpack.web.development.js
File metadata and controls
77 lines (74 loc) · 2.01 KB
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
import path from 'path';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import CopyPlugin from 'copy-webpack-plugin';
import mergeReplaceArrays from './scripts/helpers/mergeReplaceArrays.js';
import transformWebpackCopied from './scripts/helpers/transformWebpackCopied.js';
import baseConfig from './webpack.web.js';
if (process.env.NODE_ENV !== 'development') {
throw new Error('NODE_ENV isn\'t development');
}
export default mergeReplaceArrays(baseConfig, {
mode: 'development',
output: {
path: path.resolve('./build/development/web'),
filename: 'js/[name].js',
chunkFilename: 'js/chunks/[name].[chunkhash].js',
},
module: {
rules: baseConfig.module.rules.map(rule => {
if (rule.test.toString() === '/\\.(j|t)sx?$/') {
return {
...rule,
use: [
'cache-loader',
'thread-loader',
...rule.use,
],
};
}
if (rule.test.toString() === '/\\.scss$/') {
return {
...rule,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
esModule: true,
defaultExport: true,
},
},
'cache-loader',
...rule.use,
],
};
}
return rule;
}),
},
plugins: [
...baseConfig.plugins,
new MiniCssExtractPlugin({
filename: 'css/[name].css',
chunkFilename: 'css/chunks/[name].[chunkhash].css',
}),
new CopyPlugin({
patterns: [
{
from: path.resolve('./framework/web/public'),
to: path.resolve('./build/development/web'),
transform: transformWebpackCopied,
},
{
from: path.resolve('./app/web/public'),
to: path.resolve('./build/development/web'),
transform: transformWebpackCopied,
},
],
}),
// Limiting to 1 chunk is slower.
],
watchOptions: {
aggregateTimeout: 0,
},
devtool: 'cheap-module-source-map',
});