forked from SevenTV/Extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.config.js
87 lines (85 loc) · 2.09 KB
/
webpack.prod.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
const { DefinePlugin } = require('webpack');
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
module.exports = env => {
return {
mode: 'production',
entry: {
content: path.join(__dirname, 'src/Content/Content.tsx'),
background: path.join(__dirname, 'src/Background/Background.tsx'),
twitch: path.join(__dirname, 'src/Sites/twitch.tv/twitch.tsx'),
youtube: path.join(__dirname, 'src/Sites/youtube.com/youtube.tsx'),
ffz_addon: path.join(__dirname, 'src/Sites/twitch.tv/FFZ/FrankerFaceZ.Addon.ts'),
ffz_hook: path.join(__dirname, 'src/Sites/twitch.tv/FFZ/FrankerFaceZ.Hook.ts'),
},
output: { path: path.join(__dirname, env.DIST || 'dist'), filename: '[name].js' },
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.s[ac]ss$/i,
use: [
{
loader: 'file-loader',
options: { outputPath: 'styles/', name: '[name].css' }
},
'sass-loader'
]
},
{
test: /\.ts(x)?$/,
loader: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.svg$/,
use: 'file-loader',
},
{
test: /\.png$/,
use: [
{
loader: 'url-loader',
options: {
mimetype: 'image/png',
},
},
],
},
]
},
resolve: {
plugins: [new TsconfigPathsPlugin()],
extensions: ['.js', '.jsx', '.tsx', '.ts'],
alias: {
'react-dom': '@hot-loader/react-dom',
},
},
devServer: {
contentBase: './dist',
},
plugins: [
new CopyPlugin({
patterns: [
{ from: 'public/icon', to: '.', },
{ from: 'public/image', to: 'image/' },
{ from: 'public/yt_upgrade', to: 'yt_upgrade/' },
{
from: `public/manifest${env.STAGE ? '.stage' : ''}.v${env.MANIFEST_VERSION === '3' ? '3' : '2'}.json`,
to: 'manifest.json'
}
],
}),
new DefinePlugin({
global: 'window',
__ENVIRONMENT__: JSON.stringify('production'),
AppMeta: JSON.stringify({ version: 1 })
}),
],
};
};