-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.ts
72 lines (69 loc) · 1.84 KB
/
webpack.common.ts
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
import * as path from 'path';
import sass from 'sass';
import { Configuration } from 'webpack';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import WebExtPlugin from 'web-ext-plugin';
const buildTarget: string = process.env.BUILD_TARGET || 'firefox';
const config: Configuration = {
entry: {
contentScript: path.join(__dirname, 'src/content/index.ts'),
popup: path.join(__dirname, 'src/popup/index.tsx'),
},
output: {
path: path.resolve(__dirname, `dist/${buildTarget}/js`),
filename: '[name].js',
clean: true,
},
resolve: {
extensions: ['.js', '.ts', '.tsx'],
},
module: {
rules: [
{
test: /\.tsx?$/,
include: path.resolve(__dirname, 'src'),
loader: 'ts-loader',
options: {
configFile: path.resolve('./tsconfig.json'),
compilerOptions: {
noEmit: false,
},
},
},
{
test: /\.s[ac]ss$/i,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
implementation: sass,
},
},
],
},
],
},
plugins: [
new CopyWebpackPlugin({
patterns: [
{ from: 'target/shared/', to: path.resolve(__dirname, `dist/${buildTarget}`) },
{ from: `target/${buildTarget}/`, to: path.resolve(__dirname, `dist/${buildTarget}`) },
],
}),
new WebExtPlugin({
sourceDir: path.resolve(__dirname, `dist/${buildTarget}`),
artifactsDir: path.resolve(__dirname, 'dist'),
buildPackage: true,
overwriteDest: true,
outputFilename: `${buildTarget}.zip`,
startUrl: 'https://www.google.com/search?q=google',
target: buildTarget === 'firefox' ? 'firefox-desktop' : 'chromium',
}),
],
stats: {
warnings: true,
},
};
export default config;