-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
webpack.config.dev.js
149 lines (146 loc) · 3.01 KB
/
webpack.config.dev.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const JSONMinifyPlugin = require('node-json-minify');
const Dotenv = require('dotenv-webpack');
const JSconfig = {
mode: 'development',
name: 'JS',
entry: {
'background': './src/background.ts',
'inject': './src/inject.ts',
'options': './src/options.ts',
'popup': './src/popup.tsx',
},
devtool: 'inline-source-map',
output: {
path: path.resolve(__dirname, 'dist/src/'),
filename: '[name].js',
},
resolveLoader: {
modules: [
'node_modules',
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
module: {
rules: [
{
use: 'babel-loader',
test: /\.js$/,
},
{
test: /\.(ts|tsx)$/,
use: 'ts-loader',
exclude: /node_modules/
},
],
},
plugins: [
new UglifyJsPlugin({
cache: true,
parallel: true,
uglifyOptions: {
compress: false,
ecma: 6,
mangle: true
},
sourceMap: true,
}),
new Dotenv(),
],
};
const OtherFilesConfig = {
name: 'OtherFilesConfig',
mode: 'development',
entry: {
'index': './index.html',
'options': './options.html',
},
output: {
path: path.resolve(__dirname, 'dist/'),
filename: '[name].html',
},
resolveLoader: {
modules: [
'node_modules',
],
},
module: {
rules: [
{
use: [{
loader: 'html-loader',
}],
test: /\.html$/,
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
emitFile: false,
},
},
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: __dirname + '/index.html',
filename: '/index.html',
inject: 'body',
hash: true,
minify: {
removeAttributeQuotes: true,
collapseWhitespace: true,
html5: true,
removeComments: true,
removeEmptyAttributes: true,
minifyCSS: true,
},
}),
new HtmlWebpackPlugin({
template: __dirname + '/options.html',
filename: '/options.html',
inject: 'body',
hash: true,
minify: {
removeAttributeQuotes: true,
collapseWhitespace: true,
html5: true,
removeComments: true,
removeEmptyAttributes: true,
minifyCSS: true,
},
}),
new CopyWebpackPlugin([
{
from: 'img',
to: 'img',
},
{
from: 'manifest.json',
to: 'manifest.json',
},
{
from: '_locales',
transform: function (content) {
return JSONMinifyPlugin(content.toString());
},
to: '_locales',
},
]),
],
};
module.exports = [
JSconfig,
OtherFilesConfig,
];