-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
103 lines (100 loc) · 2.8 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
const path = require('path');
const autoprefixer = require('autoprefixer');
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const Dotenv = require('dotenv-webpack');
// Constant with our paths
const paths = {
DISTSCRIPTS: path.resolve(__dirname, 'dist/scripts'),
DIST: path.resolve(__dirname, 'dist'),
SRC: path.resolve(__dirname, 'src/scripts'),
SRC_HTML: path.resolve(__dirname, 'src/html')
};
module.exports = {
devServer: {
static: {
directory: path.resolve(__dirname, 'sandboxdata/TSU_Sandbox_Datafiles'),
publicPath: '/sandboxdata/TSU_Sandbox_Datafiles'
}
},
entry: {
index: path.join(paths.SRC, 'index.js'),
SandboxPlotRegion: './src/scripts/SandboxPlotRegion.js',
},
mode: 'production',
performance: {
hints: false,
maxEntrypointSize: 512000,
maxAssetSize: 512000
},
output: {
// path: paths.DISTSCRIPTS,
filename: 'scripts/[name].app.bundle.js',
chunkFilename: 'scripts/[name].js',
publicPath: ''
},
optimization: {
moduleIds: 'size',
runtimeChunk: 'single',
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
// name: 'vendors',
chunks: 'all',
},
},
}
},
resolve: {
extensions: ['.js', '.jsx']
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.s?css$/,
exclude: /node_modules/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"sass-loader",
"postcss-loader"
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: path.join('css/style.[name].css'),
chunkFilename: "[name].css"
}),
new Dotenv(),
new HtmlWebpackPlugin({
hash: true,
template: path.join(paths.SRC_HTML, 'index.html'),
filename: path.join(paths.DIST, 'index.html'),
inject: 'body',
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
},
}),
new webpack.HotModuleReplacementPlugin(),
]
};