forked from austencm/youtube-auto-like
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
75 lines (64 loc) · 2.04 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
const path = require('path');
const RunChromeExtension = require('webpack-run-chrome-extension');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ZipWebpackPlugin = require('zip-webpack-plugin');
const IS_PROD = process.env.NODE_ENV === 'production';
const paths = {
build: path.resolve(__dirname, 'dist'),
src: path.resolve(__dirname, 'src'),
};
module.exports = {
mode: IS_PROD ? 'production' : 'development',
// Where webpack looks to start building the bundle
entry: {
content: `${paths.src}/js/content.js`,
options: `${paths.src}/js/options.js`,
background: `${paths.src}/js/background.js`,
},
// Where webpack outputs the assets and bundles
output: {
path: paths.build,
filename: '[name].js',
},
// Customize the webpack build process
plugins: [
new CleanWebpackPlugin(),
new CopyWebpackPlugin({
patterns: [
`${paths.src}/manifest.json`,
{ from: `${paths.src}/*.html`, context: paths.src },
{ from: `${paths.src}/_locales`, to: `${paths.build}/_locales` },
{ from: `${paths.src}/css`, to: `${paths.build}/css` },
{ from: `${paths.src}/images`, to: `${paths.build}/images` },
],
}),
IS_PROD && new ZipWebpackPlugin({
path: '../',
filename: 'release.zip',
}),
!IS_PROD && new RunChromeExtension({
extensionPath: paths.build,
startingUrl: 'https://youtube.com',
autoReload: true,
}),
].filter(Boolean),
// Determine how modules within the project are treated
module: {
rules: [
// Images: Copy image files to build folder
{ test: /\.(?:ico|gif|png|jpg|jpeg)$/i, type: 'asset/resource' },
// Fonts and SVGs: Inline files
{ test: /\.(woff(2)?|eot|ttf|otf|svg)$/, type: 'asset/inline' },
],
},
resolve: {
modules: ['src', 'node_modules'],
},
// Control how source maps are generated
devtool: IS_PROD ? false : 'inline-source-map',
watch: !IS_PROD,
optimization: {
minimize: IS_PROD,
},
};