generated from Accuraty/AccuTheme-2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
112 lines (107 loc) · 2.83 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
104
105
106
107
108
109
110
111
112
import { resolve } from 'path';
import ESLintPlugin from 'eslint-webpack-plugin';
import TerserPlugin from 'terser-webpack-plugin';
import webpackPkg from 'webpack';
const { ProvidePlugin } = webpackPkg;
import { project, paths } from './gulpfileDir/config/index.js';
import { getWebpackEntries } from './gulpfileDir/utils/index.js';
// ES6 doesn't have __filename or __dirname global variables so this creates them for us.
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const devMode = project.mode !== 'production';
const webpackPlugins = [
new ESLintPlugin({
context: `${paths.src}/scripts`,
failOnError: false,
}),
new ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
}),
];
// The auto-convert broke up the modules.export object into individual exports.
// import * as WEBPACK_CONFIG from './Path/to/This/File' will import everything as a single object named WEBPACK_CONFIG
export const mode = project.mode;
export const entry = getWebpackEntries();
export const output = {
filename: '[name].bundle.js',
path: resolve(__dirname, paths.dist),
pathinfo: devMode,
publicPath: paths.dist.replace(paths.app, ''),
};
export const devtool = devMode ? 'eval-cheap-source-map' : false;
export const optimization = {
minimize: !devMode,
minimizer: [
new TerserPlugin({
exclude: /vendors/,
extractComments: false,
parallel: true,
terserOptions: {
compress: {
drop_console: true,
},
output: {
comments: false,
},
},
}),
],
removeEmptyChunks: !devMode,
runtimeChunk: 'single',
splitChunks: {
cacheGroups: {
defaultVendors: {
chunks: 'initial',
minChunks: 2,
minSize: 0,
name: 'vendors',
priority: -10,
reuseExistingChunk: true,
test: /[\\/]node_modules[\\/]/,
},
common: {
chunks: 'all',
enforce: true,
name: 'common',
priority: -20,
test: /[\\/]scripts\/(App|config)[\\/]/i,
},
},
},
};
export const module = {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
include: resolve(__dirname, paths.src),
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
bugfixes: true,
corejs: '3.13',
debug: false,
useBuiltIns: 'entry',
},
],
],
plugins: [
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-class-properties',
],
},
},
},
],
};
export const plugins = webpackPlugins;
export const watchOptions = {
ignored: ['./node_modules/'],
};