-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
102 lines (98 loc) · 2.34 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
102
'use strict';
const path = require('path');
const { EnvironmentPlugin } = require('webpack');
const SizePlugin = require('size-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const GoogleFontsPlugin = require('google-fonts-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const srcFolder = 'src';
const distFolder = 'dist';
const srcFileExtensions = ['.ts', '.js'];
const copyIgnoredFiles = ['*.ts', '*.js', '*.scss', '*.html'];
const apiUrls = {
development: 'http://localhost:8080',
production: 'https://botim-backend.herokuapp.com'
};
module.exports = (env, argv) => ({
devtool: 'sourcemap',
entry: {
content: [`./${srcFolder}/content.ts`, `./${srcFolder}/styles/content.scss`],
background: `./${srcFolder}/background.ts`
},
output: {
path: path.join(__dirname, distFolder),
filename: '[name].js'
},
module: {
rules: [
{
test: /\.(js|ts)$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
},
{
test: /\.png$/i,
use: 'url-loader'
},
{
test: /\.html$/i,
use: 'html-loader'
}
]
},
plugins: [
new SizePlugin(),
new EnvironmentPlugin({
API_URL: apiUrls[argv.mode]
}),
new CleanWebpackPlugin(distFolder),
new CopyWebpackPlugin([
{
from: '**/*',
context: srcFolder,
ignore: copyIgnoredFiles
},
{
from: 'node_modules/webextension-polyfill/dist/browser-polyfill.min.js'
}
]),
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css'
}),
new GoogleFontsPlugin({
fonts: [
{
family: 'Heebo',
variants: ['400', '700'],
subsets: ['hebrew']
}
],
formats: ['woff']
})
],
resolve: {
extensions: srcFileExtensions
},
optimization: {
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
mangle: false,
compress: false,
output: {
beautify: true,
indent_level: 2
}
}
})
]
}
});