-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
50 lines (46 loc) · 1.11 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
import webpack from 'webpack';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
const PROD = process.env.NODE_ENV === 'production';
const ASSET_PATH = process.env.ASSET_PATH || '/js/';
const plugins = [
// ignore moment imported by pikaday
new webpack.IgnorePlugin({
resourceRegExp: /moment$/
})
];
const config = {
watch: !PROD,
mode: PROD ? 'production' : 'development',
optimization: {
usedExports: true
},
entry: {
main: './src/js/index.ts',
journey: './src/js/journey-module.ts'
},
devtool: PROD ? false : 'inline-source-map',
stats: 'normal',
module: {
rules: [
{
// declaring no sideEffects for files with .mjs extension which is mainly swiper
test: /\.mjs$/,
sideEffects: false
},
{
test: /\.(tsx|ts|js)$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
output: {
publicPath: ASSET_PATH,
filename: '[name].bundle.js'
},
plugins: PROD ? plugins : [...plugins, new BundleAnalyzerPlugin()]
};
export default config;