-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.ts
94 lines (84 loc) · 2.34 KB
/
webpack.config.ts
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
import webpack from 'webpack';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import { VueLoaderPlugin } from 'vue-loader';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import manifestJson from './manifest.chrome.json';
export default function (
env: string,
op: webpack.Configuration
): webpack.Configuration {
const isProd = op.mode === 'production';
console.log('⌥', env, op.mode);
if (!isProd) {
console.log('Bundle anayser available at:', 'http://127.0.0.1:8888');
}
return {
mode: op.mode,
entry: {
'jsdiff-devtools': './src/jsdiff-devtools.ts',
'jsdiff-panel': './src/jsdiff-panel.js',
'jsdiff-proxy': './src/jsdiff-proxy.ts',
'jsdiff-console': './src/jsdiff-console.ts',
'firefox/jsdiff-background': './src/firefox/background-script.ts',
},
output: {
filename: '[name].js',
path: new URL('bundle/js', import.meta.url).pathname,
},
resolve: {
extensions: ['.ts', '.js'],
modules: [new URL('src/js', import.meta.url).pathname, 'node_modules'],
alias: {
'@': new URL('src', import.meta.url).pathname,
},
},
plugins: [
new CleanWebpackPlugin(),
new VueLoaderPlugin(),
isProd
? () => {}
: new BundleAnalyzerPlugin({
// http://127.0.0.1:8888
openAnalyzer: false,
logLevel: 'silent',
}),
new webpack.DefinePlugin({
__VUE_OPTIONS_API__: 'false',
__VUE_PROD_DEVTOOLS__: 'false',
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',
__development__: `${!isProd}`,
__app_version__: `"${manifestJson.version}"`,
__app_homepage__: `"${manifestJson.homepage_url}"`,
}),
],
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'esbuild-loader',
options: {
loader: 'ts',
target: 'es2022',
},
},
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.(scss|css)$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.svg/,
type: 'asset/resource',
},
],
},
optimization: {
splitChunks: false,
minimize: isProd,
},
devtool: isProd ? false : 'source-map',
};
}