-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
40 lines (38 loc) · 1.04 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const webpack = require('webpack');
const mode = process.argv[3] || 'development';
const OPTIONS = {
ENTRY: {
production: './src/client/tracker.js',
development: './src/index.js',
},
OUTPUT_PATH: {
production: 'build',
development: 'dist',
},
OUTPUT_FILENAME: {
production: 'jstracker.js',
development: 'main.js',
},
};
module.exports = {
mode,
entry: OPTIONS.ENTRY[mode],
devtool: 'inline-source-map',
plugins: mode === 'production' ? [new CleanWebpackPlugin([OPTIONS.OUTPUT_PATH[mode]])] : [
new CleanWebpackPlugin([OPTIONS.OUTPUT_PATH[mode]]),
new HtmlWebpackPlugin({
title: 'Output Management',
}), new webpack.HotModuleReplacementPlugin(),
],
devServer: {
contentBase: './dist',
},
output: {
path: path.resolve(__dirname, OPTIONS.OUTPUT_PATH[mode]),
filename: OPTIONS.OUTPUT_FILENAME[mode],
globalObject: 'this',
},
};