-
Notifications
You must be signed in to change notification settings - Fork 1
/
kyt.config.js
75 lines (70 loc) · 2.38 KB
/
kyt.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 HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const WriteFilePlugin = require('write-file-webpack-plugin');
const path = require('path');
const aliasesConfig = require('./webpack.aliases.config.js');
const packageJSON = require('./package.json');
module.exports = {
reactHotLoader: false,
debug: false,
hasServer: false,
clientURL: 'http://localhost:3002',
modifyWebpackConfig: (config, options) => {
if (options.type === 'client') {
// Aliases
config.resolve.alias = {
...(config.resolve.alias || {}),
...aliasesConfig.resolve.alias,
};
config.devtool = 'source-map';
// config.entry.background = './src/background/index.js';
// config.entry.contentScript = './src/contentScript/index.js';
config.entry.popup = './src/popup/index.js';
delete config.entry.main;
if (config.devServer) config.devServer.publicPath = '.';
config.output.publicPath = '.';
if (options.environment === 'production') {
config.optimization = {};
config.output.filename = '[name].js';
config.output.chunkFilename = '[name].js';
}
config.plugins.push(
new CopyWebpackPlugin([
{
from: 'src/manifest.json',
transform(content) {
// Overwrite manifest.json with metadata from package.json
return Buffer.from(
JSON.stringify({
...JSON.parse(content.toString()),
name: packageJSON.name,
description: packageJSON.description,
version: packageJSON.version,
})
);
},
},
{
from: 'src/public/**/*',
transformPath: (target) => {
return target.replace(/src\/public\//, '');
},
},
{
from: 'node_modules/web-vitals/dist/web-vitals.umd.js',
transformPath: (target) => {
return target.replace(/node_modules\/web-vitals\/dist\//, '');
},
},
]),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src/popup', 'popup.ejs'),
filename: 'popup.html',
chunks: ['popup'],
}),
new WriteFilePlugin({ test: /^(?!.*(hot)).*/ })
);
}
return config;
},
};