generated from SU-SWS/stanford_starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
101 lines (97 loc) · 2.67 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
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 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: {
"main": ["./src/scss/main.scss"],
"full-width.basic-page": ["./src/scss/basic-page/full-width.scss"],
"ckeditor5": ["./src/scss/ckeditor5.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: /\.behavior.js$/,
exclude: /node_modules/,
options: {
enableHmr: false
},
loader: 'drupal-behaviors-loader'
},
{
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: {}},
{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;