-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.old.js
91 lines (90 loc) · 3.33 KB
/
webpack.config.old.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
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin'); // Add this line
const CircularDependencyPlugin = require('circular-dependency-plugin')
const webpack = require('webpack');
const packageJson = require('./package.json');
const prevVersion = packageJson.version;
module.exports = (env, argv) => {
return {
target: 'web',
entry: './browser.js', // Update this with your entry file
output: {
filename: 'weploy-translate.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
{
test: /\.css$/,
oneOf: [
{
resourceQuery: /raw/, // foo.css?raw
use: [
'raw-loader',
],
},
{
use: [
MiniCssExtractPlugin.loader,
'css-loader',
],
},
],
},
// {
// test: /\.css$/,
// exclude: /weploy\.css$/,
// use: 'null-loader', // Ignore other CSS files
// },
],
},
plugins: [
new MiniCssExtractPlugin({
filename: 'weploy-translate.css',
chunkFilename: '[id].css',
}),
new CircularDependencyPlugin({
// exclude detection of files based on a RegExp
exclude: /node_modules/,
// include specific files based on a RegExp
include: /dir/,
// add errors to webpack instead of warnings
failOnError: true,
// allow import cycles that include an asyncronous import,
// e.g. via import(/* webpackMode: "weak" */ './file.js')
allowAsyncCycles: false,
// set the current working directory for displaying module paths
cwd: process.cwd(),
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(argv.mode),
NO_CACHE: JSON.stringify(env.NO_CACHE),
BRAND: JSON.stringify('weploy'),
CSS_PATH: JSON.stringify('../../globalseo.css'),
CSS_PATH_RAW: JSON.stringify('../../globalseo.css?raw'),
PREV_SCRIPT_VERSION: JSON.stringify(prevVersion),
},
}),
],
optimization: {
minimize: true,
minimizer: [
new CssMinimizerPlugin(),
new TerserPlugin(), // Add this line
],
},
};
};