generated from mnao305/webextension-typescript-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.ts
58 lines (55 loc) · 1.6 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
import path from 'path'
import CopyWebpackPlugin from 'copy-webpack-plugin'
import { Configuration } from 'webpack'
import { name, version } from './package.json'
const config = (_: any, argv: any): Configuration => {
return {
devtool: argv.mode === 'production' ? false : 'inline-source-map',
context: path.join(__dirname, 'src'),
entry: {
popup: './popup/index.ts',
options: './options/index.ts',
background: './background/index.ts',
content: './content/index.ts'
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name]/index.js'
},
module: {
rules: [
{
test: /.ts$/,
use: 'ts-loader',
exclude: '/node_modules/'
}
]
},
resolve: {
extensions: ['.ts', '.js']
},
plugins: [
new CopyWebpackPlugin({
patterns: [
{ from: 'icons', to: 'icons' },
{ from: 'popup/index.html', to: 'popup/index.html' },
{ from: 'popup/style.css', to: 'popup/style.css' },
{ from: 'options/index.html', to: 'options/index.html' },
{ from: 'options/style.css', to: 'options/style.css' },
{
from: 'manifest.json',
to: 'manifest.json',
transform: (content) => {
const jsonContent = JSON.parse(content.toString())
jsonContent.version = version
jsonContent.name = name
return JSON.stringify(jsonContent, null, 2)
}
},
{ from: '_locales', to: '_locales' }
]
})
]
}
}
export default config