-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
121 lines (118 loc) · 2.63 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ChromeExtensionReloader = require('webpack-chrome-extension-reloader');
const config = {
entry: {
background: "./src/background/index.ts",
popup: "./src/popup/popup.ts",
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader'
},
{
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.vue$/],
}
}
]
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
],
},
{
test: /\.less$/,
use: [
'vue-style-loader',
'css-loader',
'less-loader'
]
},
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8192
}
}
]
}
]
},
optimization: {
splitChunks: {
name: "vendor",
chunks: "async",
},
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': path.resolve(__dirname, './src'),
},
extensions: ['*', '.tsx', '.ts', '.js', '.vue', '.json'],
},
output: {
filename: "[name]/[name].js",
path: path.resolve(__dirname, "dist/"),
},
plugins: [
new CopyWebpackPlugin([
{
from: "./src/manifest.json",
to: "./manifest.json",
},
{
from: "./src/images/",
to: "images/",
},
]),
new VueLoaderPlugin(),
new CleanWebpackPlugin(['dist']),
new HtmlWebpackPlugin({
filename: 'popup/popup.html',
template: 'src/popup/popup.html',
chunks: ['popup'],
hash: true,
}),
]
};
module.exports = (env, argv) => {
if (argv.mode === 'development') {
config.devtool = 'inline-source-map';
config.plugins.push(
new ChromeExtensionReloader({
port: 9090, // Which port use to create the server
reloadPage: true, // Force the reload of the page also
entries: { // The entries used for the content/background scripts
background: 'background',
},
})
);
}
return config;
};