generated from SU-SWS/stanford_starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
100 lines (96 loc) · 2.62 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
const path = require("path");
const Webpack = require("webpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const FixStyleOnlyEntriesPlugin = require("webpack-fix-style-only-entries");
const FileManagerPlugin = require('filemanager-webpack-plugin');
const autoprefixer = require('autoprefixer')({ grid: true });
const config = {
isProd: process.env.NODE_ENV === "production",
hmrEnabled: process.env.NODE_ENV !== "production" && !process.env.NO_HMR,
distFolder: path.resolve(__dirname, "./dist/css"),
wdsPort: 3001,
};
var webpackConfig = {
entry: {
"chem_h_subtheme": "./src/scss/config/index.scss",
},
output: {
path: config.distFolder,
filename: '[name].js',
assetModuleFilename: '../assets/[name][ext][query]'
},
mode: config.isProd ? "production" : "development",
resolve: {
alias: {
'decanter-assets': path.resolve('node_modules', 'decanter/core/src/img'),
'decanter-src': path.resolve('node_modules', 'decanter/core/src'),
'@fortawesome': path.resolve('node_modules', '@fortawesome'),
'fa-fonts': path.resolve('node_modules', '@fortawesome/fontawesome-free/webfonts')
}
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
},
},
{
test: /\.(sa|sc|c)ss$/,
use: [
config.isProd ? { loader: MiniCssExtractPlugin.loader } : 'style-loader',
{loader:'css-loader', options: {}},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
sourceMap: true,
plugins: [autoprefixer],
},
}
},
{loader:'sass-loader', options: {}}
]
},
{
test: /\.(png|jpg|gif|svg)$/i,
type: "asset"
},
{
test: /\.(woff|woff2|eot|ttf)$/i,
type: "asset",
generator: {
filename: '../assets/fonts/[name][ext][query]'
}
}
]
},
plugins: [
new FixStyleOnlyEntriesPlugin(),
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new FileManagerPlugin({
events: {
onStart: {
delete: ["dist"]
}
}
}),
],
optimization: {
minimizer: [
new OptimizeCSSAssetsPlugin(),
]
}
};
if (config.hmrEnabled) {
webpackConfig.plugins.push(new Webpack.HotModuleReplacementPlugin());
}
module.exports = webpackConfig;