-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
94 lines (92 loc) · 2.2 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
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const packageJson = require('./package.json');
/**
* Webpack Production Configuration
*/
module.exports = {
entry: {
background: path.resolve('src', 'background', 'background.ts'),
content_script: [
path.resolve('src', 'content_script', 'content_script.ts'),
path.resolve('src', 'content_script', 'content_script.scss'),
],
},
output: {
path: path.resolve('dist', 'src'),
filename: '[name].js',
},
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
exclude: /node_modules/,
test: /\.ts$/,
use: ['ts-loader'],
},
{
test: /\.scss$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].css',
},
},
'extract-loader',
'css-loader',
'sass-loader',
],
},
],
},
plugins: [
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve('src', 'manifest.json'),
to: path.resolve('dist'),
transform: (contents) => {
const manifestJson = JSON.parse(contents.toString());
const newManifestJson = {
// Specific order!
name: manifestJson.name,
description: packageJson.description,
version: packageJson.version,
homepage_url: packageJson.homepage,
...manifestJson,
};
return JSON.stringify(newManifestJson, null, '\t');
},
},
{
from: path.resolve('assets', 'icon-16.png'),
to: path.resolve('dist'),
},
{
from: path.resolve('assets', 'icon-48.png'),
to: path.resolve('dist'),
},
{
from: path.resolve('assets', 'icon-128.png'),
to: path.resolve('dist'),
},
],
}),
],
optimization: {
splitChunks: {
cacheGroups: {
default: false,
commons: {
test: /node_modules/,
name: 'vendor',
chunks: 'initial',
minSize: 1,
},
},
},
},
};