generated from rweich/userscript-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
99 lines (95 loc) · 2.46 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
95
96
97
98
99
import path from 'node:path';
import { VueLoaderPlugin } from 'vue-loader';
import * as webpack from 'webpack';
import WebpackUserscript from 'webpack-userscript';
import generateHeaders from './src/Header';
const config = (
environment: { BUILD_VERSION?: string },
options: { mode: string; env: unknown },
): webpack.Configuration => {
const isDevelopment = options.mode === 'development';
const headers = generateHeaders(isDevelopment, environment.BUILD_VERSION || undefined);
return {
/* eslint-disable sort-keys */
entry: path.resolve(__dirname, 'src', 'index.ts'),
target: 'web',
output: {
filename: `${headers.name}.js`,
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
},
resolve: {
extensions: ['.js', '.vue', '.json', '.ts'],
alias: {
'@': path.resolve(__dirname, 'src/'),
},
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
appendTsSuffixTo: [/\.vue$/],
},
},
{
test: /\.css$/i,
use: ['vue-style-loader', 'css-loader'],
},
{
test: /\.(png|jpg|svg|eot|ttf|woff)$/,
type: 'asset/inline',
},
{
test: /\.s[ac]ss$/,
use: [
'vue-style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
implementation: require('sass'),
},
},
],
},
],
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
disableHostCheck: true,
headers: {
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept',
'Access-Control-Allow-Origin': '*',
},
host: 'localhost',
https: false,
port: 11_944,
},
plugins: [
new WebpackUserscript({
headers: headers,
pretty: true,
proxyScript: {
baseUrl: 'http://localhost:11944/',
enable: isDevelopment,
filename: '[basename].proxy.user.js',
},
}),
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
new VueLoaderPlugin(),
],
optimization: {
minimize: false,
},
/* eslint-enable sort-keys */
};
};
export default config;