-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.disabled.cjs
55 lines (50 loc) · 1.47 KB
/
webpack.config.disabled.cjs
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
/* ================================================= */
/* -- COMMON JS MODULE --------------------------- */
/* ================================================= */
const path = require('path');
// const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// set NODE_ENV to 'development' by default
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
// is 'development' the current NODE_ENV?
const dev = process.env.NODE_ENV === 'development';
function resolvePath(a, b = '', c = ''){
return path.resolve(__dirname, a, b, c);
}
module.exports = {
mode: dev ? 'development' : 'production',
devtool: dev ? 'source-map' : undefined,
plugins: [
// new webpack.ProgressPlugin(),
new HtmlWebpackPlugin({ template: resolvePath('src', 'index.html') }),
new MiniCssExtractPlugin()
],
entry: resolvePath('src', 'index.js'),
output: {
path: resolvePath('build'),
filename: 'app.js'
},
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx|json)$/,
include: resolvePath('src'),
exclude: /node_modules/,
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json']
},
use: [
{ loader: 'babel-loader' }
]
},
{
test: /\.(css|scss|less)$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' }
]
}
]
}
};