forked from mlsof21/voice-dim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
57 lines (54 loc) · 1.61 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
const path = require('path');
const dotenv = require('dotenv-webpack');
const CopyPlugin = require('copy-webpack-plugin');
const { CleanPlugin } = require('webpack');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
const srcDir = path.join(__dirname, 'src', 'ts');
const browsers = ['chrome', 'firefox'];
const configs = browsers.map((browser) => {
return {
entry: {
background: path.join(srcDir, 'background.ts'),
voiceDim: path.join(srcDir, 'voiceDim.ts'),
options: path.join(srcDir, 'options.ts'),
common: path.join(srcDir, 'common.ts'),
},
output: {
path: path.join(__dirname, 'dist', browser, 'js'),
filename: '[name].js',
clean: true,
},
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
},
],
},
plugins: [
new CleanPlugin({ verbose: false }),
new CopyPlugin({
patterns: [
{ from: 'icons/', to: '../icons/', context: 'public' },
{ from: `./manifest.${browser}.json`, to: '../manifest.json', context: 'public' },
{ from: 'html/', to: '../html/', context: 'src' },
{ from: 'css/', to: '../css/', context: 'src' },
],
}),
new dotenv(),
new NodePolyfillPlugin(),
],
devtool: 'inline-source-map',
};
});
module.exports = (env) => {
console.log({ configs });
return configs.map((config) => {
return { ...config, mode: env.mode };
});
};