-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.ts
72 lines (60 loc) · 2.22 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
const path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
let webpack = require('webpack')
const mode = process.env.NODE_ENV === 'production' ? 'production' : 'development'
const config = {
devtool: 'source-map',
mode,
entry: {
// browser specific scripts (where browser specific API resides)
background: './src/browser/background.ts',
contentscript: './src/browser/contentscript.ts',
// options_script.js is embedded in options.html
options_script: './src/browser/options_script.ts', // this is the script for click-in-text configuration page
// this script imitates contentscript.ts and allows integration tests to be run by mocking browser APIs
test: './src/embedded/test.ts',
embedded: './src/embedded/embedded.ts'
},
resolve: {
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js'],
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
// All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'.
{test: /\.tsx?$/, loader: 'ts-loader'},
// // All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
// {test: /\.js$/, loader: 'source-map-loader'},
// used to load popup.html and tat_popup.html in js
{test: /\.html$/i, loader: 'html-loader',}
]
},
plugins: [
new CleanWebpackPlugin(['dist']),
// files that directly copy to ./dist/ in a flatterned way
new CopyWebpackPlugin(
[
'src/browser/manifest.json',
// todo: consider getting rid of these by writing them in JS
'src/embedded/test.html',
'src/browser/options.html',
'node_modules/xregexp/xregexp-all.js'
], {to: 'dist'}
),
// icon images that go to ./dist/icons
new CopyWebpackPlugin(
[
'icons/*.png',
], {context: 'src', to: 'dist'}
),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}) // this makes $ and jQuery globally recognizable and automatically packed in this project. (FYI, this setup by default looks for 'jquery' in node_modules)
],
}
module.exports = config