-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
74 lines (62 loc) · 1.91 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
const path = require('path');
const TerserPlugin = require("terser-webpack-plugin");
const BundleTracker= require('webpack-bundle-tracker');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
// Path definitions
const entrypoints = {
main: {
import: './_front/ts/main.ts',
},
}
const production_path = {
dest: path.resolve(__dirname, '_static/dist'),
pub: '/static/dist/'
}
const development_path = {
dest: path.resolve(__dirname, '_static/src'),
pub: '/static/src/'
}
module.exports = env => {
let dev_mode = env.development || false;
let build_path = dev_mode ? development_path : production_path;
return {
mode: dev_mode ? 'development' : 'production',
devtool: dev_mode ? 'inline-source-map' : 'nosources-source-map',
entry: entrypoints,
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.css$/i,
include: path.resolve(__dirname, "_front"),
use: ["style-loader", "css-loader", "postcss-loader"],
}
]
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
plugins: [
new CleanWebpackPlugin(),
new BundleTracker({
path: __dirname,
filename: 'webpack-stats.json'
}),
],
optimization: {
minimize: true,
minimizer: [new TerserPlugin({
extractComments: false,
})],
},
output: {
filename: dev_mode ? '[name].js' : '[name].min.js',
path: build_path.dest,
publicPath: build_path.pub
}
}
}