-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
139 lines (125 loc) · 2.79 KB
/
webpack.config.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**
* External dependencies
*/
import path from 'path';
/**
* Internal dependencies
*/
import {
isProd,
bundlerSrc,
bundlerDest,
} from './gulp/constants';
import {
watch,
jsRules,
minimize,
minimizer,
externals,
} from './gulp/webpack/base';
/**
* The entry path.
*
* The bundler entry path must resolve to `Assets/js/src/bundler`
* so when exporting the project, all bundled files are exported as well.
*
* If different directory is to be set, change value for `bundlerSrc`
* present inside `constants.js` instead. That way, all path mapped using
* that constant gets propagated accordingly.
*/
const entryPath = path.resolve( bundlerSrc );
/**
* The output path.
*
* The bundler destination path must resolve to `Assets/js/dist`
* so when exporting the project, all bundled files are exported as well.
*
* If different directory is to be set, change value for `bundlerDest`
* present inside `constants.js` instead. That way, all path mapped using
* that constant gets propagated accordingly.
*/
const destPath = path.resolve( bundlerDest );
/**
* The entry files.
*
* If entry has no data, webpack won't run at all.
* Use const `entryPath` when adding entry file path.
*
* @see bundleScripts()
* @file `gulp/webpack/webpack.js`.
* @link https://webpack.js.org/concepts/entry-points/
*/
const entry = {};
/**
* The output files.
*
* Since, bundler is watched (not by webpack) by the gulp watch,
* we are directly saving final bundled file with a `*.min.js`
* to comply with how other script files are served.
*
* @link https://webpack.js.org/concepts/output/
*/
const output = {
filename: '[name].min.js',
path: destPath,
};
/**
* The modules to use.
*
* @link https://webpack.js.org/configuration/module/
*/
const module = {
rules: [
jsRules,
// Add rules for other file types (hint: css, image).
],
};
/**
* Optimization options.
*
* @link https://webpack.js.org/configuration/optimization/#optimizationminimizer
*/
const optimization = {
minimize,
minimizer,
// Any other optimization codes here.
};
/**
* Devtool (sourcemap) option.
*
* Don't generate sourcemap on production, otherwise inline sourcemap.
* This is to comply with how other script files are served.
*
* @link https://webpack.js.org/configuration/devtool/
*/
const devtool = isProd ? false : 'inline-source-map';
/**
* The plugins to use.
*
* @link https://webpack.js.org/concepts/plugins/#configuration
*/
const plugins = [
// Any plugins to use here.
];
/**
* Current environment.
*
* https://webpack.js.org/configuration/mode/
*/
const mode = isProd ? 'production' : 'development';
/**
* Webpack Configuration for gulp task.
*
* https://webpack.js.org/configuration/
*/
export default {
watch,
entry,
output,
module,
plugins,
externals,
optimization,
devtool,
mode,
};