forked from EurekaScratch/eureka
/
webpack.config.js
101 lines (98 loc) · 3.02 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 svgToMiniDataURI = require('mini-svg-data-uri');
const webpack = require('webpack');
const path = require('path');
const { UserscriptPlugin } = require('webpack-userscript');
const { includeURLs } = require('./generate-helper');
const packageJSON = require('./package.json');
const process = require('node:process');
const standalone = {
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
entry: './src/index.ts',
output: {
// eslint-disable-next-line no-undef
path: path.resolve(__dirname, 'dist'),
publicPath: './',
filename: 'eureka-loader.js'
},
resolve: {
extensions: ['.ts', '.js', '.tsx', '.jsx']
},
module: {
rules: [
{
test: /\.worker\.ts$/,
use: {
loader: 'codingclip-worker-loader',
options: {
filename: '[name].js',
inline: 'fallback'
}
}
},
{
test: /\.tsx?/,
use: ['babel-loader'],
exclude: /node_moudles/
},
{
test: /\.(png|jpg|gif)$/,
type: 'asset/inline'
},
{
test: /\.svg$/,
type: 'asset/inline',
generator: {
dataUrl: (content) => svgToMiniDataURI(content.toString())
}
}
]
},
plugins: [
new UserscriptPlugin({
headers: {
name: packageJSON.displayName,
author: packageJSON.author,
namespace: 'EurekaLoader',
source: packageJSON.repository,
description: packageJSON.description,
version: packageJSON.version,
license: packageJSON.license,
grant: ['none'],
updateURL: 'https://eureka.codingclip.cc/release/eureka-loader.user.js',
downloadURL: 'https://eureka.codingclip.cc/release/eureka-loader.user.js',
'run-at': 'document-start',
include: includeURLs
},
pretty: true,
strict: true,
whitelist: true
}),
new webpack.DefinePlugin({
__EUREKA_VERSION__: JSON.stringify(packageJSON.version)
})
]
};
const charlotte = {
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
target: 'web',
entry: './src/charlotte.ts',
experiments: {
outputModule: true
},
output: {
library: {
type: 'module'
},
path: path.resolve(__dirname, 'dist'),
publicPath: './',
filename: 'eureka-charlotte.js'
},
resolve: standalone.resolve,
module: standalone.module,
plugins: [
new webpack.DefinePlugin({
__EUREKA_VERSION__: JSON.stringify(packageJSON.version)
})
]
}
module.exports = [standalone, charlotte];