-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
106 lines (101 loc) · 3.5 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
102
103
104
105
106
const CopyPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const TerserPlugin = require("terser-webpack-plugin");
const config = {
entry: {
background: './src/background.ts',
content: './src/content.ts',
contentCss: './src/content.scss',
'options_ui': './src/options_ui/options_ui.ts',
'internal_pages_script': './src/internal_pages/common_script.ts',
},
output: {
filename: '[name].js',
path: __dirname + '/dist'
},
module: {
rules: [
{
test: /\.tsx?$/, use: {
loader: 'ts-loader',
}
},
{
test: /\.pug$/,
// use: [
// // 'html-loader',
// 'pug-html-loader'
// ],
use: [
//{
// loader: 'html-loader',
// options: { minimize: false }
//},
{
loader: 'raw-loader',
},
{
loader: 'pug-html-loader',
options: { pretty: true }
}
]
},
{ test: /\.styl(us)?$/, use: [ 'css-loader', 'stylus-loader' ] },
{ test: /\.(gif|svg|jpg|png)$/, loader: "file-loader" },
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
{
test: /\.scss$/i, use: [
{
loader: 'file-loader',
options: { outputPath: '', name: '[name].css' }
},
"sass-loader"
]
}
]
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/options_ui/options_ui.pug',
filename: 'options_ui.html',
chunks: [], // 'options_ui' // IMPORTANT: If you don't add this manually, this shitty HtmlWebpackPlugin will add ALL entries into options_ui.html...
}),
new HtmlWebpackPlugin({
template: './src/internal_pages/updated.pug',
filename: 'internal_pages/updated.html',
chunks: [], // IMPORTANT: If you don't add this manually, this shitty HtmlWebpackPlugin will add ALL entries into <script>
}),
new HtmlWebpackPlugin({
template: './src/internal_pages/download_count.pug',
filename: 'internal_pages/download_count.html',
chunks: [], // IMPORTANT: If you don't add this manually, this shitty HtmlWebpackPlugin will add ALL entries into <script>
}),
new CopyPlugin([
{ from: 'src/internal_pages/common_style.css', to: 'internal_pages/common_style.css', force: true, toType: 'file' },
]),
new CopyPlugin([
{ from: 'src/options_ui/style/', to: 'options_ui_style/', force: true, toType: 'dir' },
]),
]
}
module.exports = (env, argv) => {
console.log('mode =', argv.mode)
if (argv.mode === 'development') {
config.devtool = 'source-map';
}
if (argv.mode === 'production') {
config.plugins.push(
new TerserPlugin({
terserOptions: {
compress: {
drop_console: true,
}
}
})
)
}
return config
};