-
Notifications
You must be signed in to change notification settings - Fork 15
/
webpack.config.dev.js
65 lines (63 loc) · 1.67 KB
/
webpack.config.dev.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
const TerserPlugin = require('terser-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const config = {
mode: process.env.NODE_ENV || 'development',
optimization: {
minimize: process.env.NODE_ENV !== 'development',
minimizer:
process.env.NODE_ENV !== 'development'
? [
new TerserPlugin({
cache: true,
parallel: true,
sourceMap: true, // Must be set to true if using source-maps in production
terserOptions: {},
}),
new CssMinimizerPlugin(),
]
: [],
},
entry: {
example: path.join(__dirname, 'example/example.tsx'),
},
devtool: process.env.NODE_ENV !== 'development' ? false : 'inline-source-map',
module: {
rules: [
{
test: /\.(js|ts|tsx)$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.css$/,
exclude: /(node_modules)/,
use: ['style-loader', 'css-loader'],
},
],
},
devServer: {
contentBase: path.resolve(__dirname, 'examples/'),
compress: true,
port: 8000,
stats: 'errors-only',
open: true,
},
output: {
path: path.join(__dirname, 'example/'),
filename: '[name].min.js',
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
}),
],
resolve: {
extensions: ['.tsx', '.ts', '.js'],
modules: [path.join(__dirname, './src'), path.join(__dirname, './node_modules')],
},
};
module.exports = config;