-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
101 lines (97 loc) · 2.86 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
// const ExtensionReloader = require('webpack-extension-reloader');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const fileExtensions = ['jpg', 'jpeg', 'png', 'gif', 'eot', 'otf', 'svg', 'ttf', 'woff', 'woff2'];
const options = {
mode: process.env.NODE_ENV || 'development',
entry: {
iframe: path.join(__dirname, 'src', 'iframe.scss'),
content: path.join(__dirname, 'src', 'content.ts'),
popup: path.join(__dirname, 'src', 'popup.ts'),
options: path.join(__dirname, 'src', 'options.ts'),
background: path.join(__dirname, 'src', 'background/index.ts'),
},
output: {
path: path.join(__dirname, 'build'),
filename: '[name].bundle.js',
},
module: {
rules: [
{ test: /\.tsx?$/, loader: 'awesome-typescript-loader' },
{
test: new RegExp(`.(${fileExtensions.join('|')})$`),
loader: 'file-loader?name=[name].[ext]',
exclude: /node_modules/,
},
{
test: /\.module\.s(a|c)ss$/,
loader: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: true,
sourceMap: process.env.NODE_ENV === 'development',
},
},
{
loader: 'sass-loader',
options: {
sourceMap: process.env.NODE_ENV === 'development',
},
},
],
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
],
exclude: /node_modules/,
},
{
test: /\.s(a|c)ss$/,
exclude: /\.module.(s(a|c)ss)$/,
loader: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'sass-loader',
options: {
sourceMap: process.env.NODE_ENV === 'development',
},
},
],
},
],
},
resolve: {
extensions: fileExtensions
.map((extension) => `.${extension}`)
.concat(['.jsx', '.js', '.tsx', '.ts', '.css']),
},
plugins: [
// new ExtensionReloader({
// entries: {
// contentScript: 'content',
// background: 'background',
// optionsScript: 'options',
// extensionPage: ['popup', 'options'],
// },
// }),
new MiniCssExtractPlugin(),
new CopyWebpackPlugin([
{ from: path.join(__dirname, 'src', 'manifest.json') },
{ from: path.join(__dirname, 'src', 'background.html') },
{ from: path.join(__dirname, 'src', 'popup.html') },
{ from: path.join(__dirname, 'src', 'options.html') },
{ from: path.join(__dirname, 'src', 'uikit.css') },
]),
],
};
if (process.env.NODE_ENV === 'development') {
options.devtool = 'cheap-module-eval-source-map';
}
module.exports = options;