-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
58 lines (43 loc) Β· 1.51 KB
/
webpack.config.js
File metadata and controls
58 lines (43 loc) Β· 1.51 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
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const INITIAL_MESSAGE = 'β¨ RUNNING INITIAL BUILD π₯ π'
console.log('\n----------------------------------------------------------------------------\n');
console.log(' ', INITIAL_MESSAGE);
console.log('\n----------------------------------------------------------------------------\n');
const WEBPACK_CONFIG = {};
const SRC_DIR = path.resolve(__dirname, 'src');
const OUTPUT_DIR = path.resolve(__dirname, 'dist');
const OUTPUT_DIR_ASSETS = path.resolve(OUTPUT_DIR, 'assets');
// DEFINING WEBPACK MODEπ«π
WEBPACK_CONFIG.mode = 'development';
// DEFINING ENTRY POINT β
const entry = {
app: [path.resolve(SRC_DIR, 'index.js')]
};
WEBPACK_CONFIG.entry = entry;
// DEFINING OUPUT β‘οΈ
const output = {
filename: '[name].bundle.js',
path: OUTPUT_DIR,
publicPath: OUTPUT_DIR_ASSETS
};
WEBPACK_CONFIG.output = output;
// DEFINING MODULE PROPERTY π€©
WEBPACK_CONFIG.module = {};
// DEFINING MODULE RULES, CONFIGURING LOADERS INSIDE RULES ππ€π»
WEBPACK_CONFIG.module.rules = [];
// DEFINING THE BABEL LOADER FOR JS ππ»βοΈ
WEBPACK_CONFIG.module.rules.push({
test: '/\.js$/',
include: [SRC_DIR],
loader: 'babel-loader'
});
// DEFINING PLUGINS π¦
WEBPACK_CONFIG.plugins = [];
WEBPACK_CONFIG.plugins.push(new CleanWebpackPlugin({
verbose: true
}))
// SETTING SOURCEMAP βοΈ
WEBPACK_CONFIG.devtool = 'source-map';
// EXPORTING THE WEBPACK CONFIG ππ
module.exports = WEBPACK_CONFIG;