-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
103 lines (101 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 CompressionPlugin = require('compression-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const TerserJSPlugin = require("terser-webpack-plugin");
const webpack = require('webpack');
const ASSET_PATH = process.env.ASSET_PATH || '/';
module.exports = {
entry: path.join(__dirname, "src", "mattsogreat.js"),
output: {
path: path.join(__dirname, "build"),
publicPath: ASSET_PATH,
filename: "index.bundle.js"
},
mode: process.env.NODE_ENV || "development",
devtool: "source-map",
resolve: {
modules: [path.resolve(__dirname, "src"), "node_modules"]
},
module: {
rules: [
{
// this is so that we can compile any React,
// ES6 and above into normal ES5 syntax
test: /\.(js|jsx)$/,
// we do not want anything from node_modules to be compiled
exclude: /node_modules/,
use: ["react-hot-loader/webpack", "babel-loader"],
resolve: { extensions: [".js", ".jsx"] }
},
{
test: /\.(sa|sc|c)ss$/,
use: [
"style-loader", // creates style nodes from JS strings
"css-loader", // translates CSS into CommonJS
'postcss-loader', // can be handy for browser support
{
loader: "sass-loader",
options: {
// Prefer `dart-sass`
implementation: require('sass'),
sassOptions: {
fiber: require('fibers'),
},
} // compiles Sass to CSS, using Node Sass by default
}
]
},
{
test: /\.svg$/,
use: [
"babel-loader",
{
loader: "react-svg-loader",
options: {
svgo: {
plugins: [
{ removeTitle: false }
],
floatPrecision: 2
}
}
}
]
},
{
test: /\.(jpg|jpeg|png|gif|mp3)$/,
loaders: ["file-loader"]
}
]
},
optimization: {
minimize: true,
minimizer: [new TerserJSPlugin({}), new OptimizeCSSAssetsPlugin({})],
splitChunks: {
cacheGroups: {
styles: {
chunks: "all",
enforce: true,
name: "matty-styles",
test: /\.css$/
}
}
}
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
template: path.join(__dirname, "src", "index.html")
}),
new CompressionPlugin(),
new CopyPlugin({
patterns: [
{ from: 'src/manifest.webmanifest' },
{ from: 'src/browserconfig.xml' },
{ from: 'src/img/', to: "img" }
],
}),
]
};