-
Notifications
You must be signed in to change notification settings - Fork 0
/
webext.config.js
47 lines (46 loc) · 1.31 KB
/
webext.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
const path = require('path')
const { merge } = require('webpack-merge')
const { get } = require('lodash')
const CopyPlugin = require('copy-webpack-plugin')
const RemovePlugin = require('remove-files-webpack-plugin')
module.exports = {
webpack: (config, { src, target, dev, vendor }) => {
var target = path.resolve(target.replace('[vendor]', vendor))
config.devtool = false
config.module = merge(config.module ?? {}, {
noParse: [/main\.js$/],
rules: get(config, 'module.rules', []).concat([
{
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
type: 'asset'
}
])
})
config.plugins = get(config, 'plugins', []).concat([
new CopyPlugin({
patterns: [
{
context: path.resolve(src),
from: './assets/js/main.bundle',
to: 'assets/js/main.js'
}
]
}),
new RemovePlugin({
after: {
root: `${target}/assets/js`,
include: ['main.bundle']
}
})
])
config.resolve = merge(get(config, 'config.resolve', {}), {
alias: {
'react': 'preact/compat',
'react-dom/test-utils': 'preact/test-utils',
'react-dom': 'preact/compat',
'react/jsx-runtime': 'preact/jsx-runtime'
}
})
return config
}
}