forked from flyerman/lace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.app.js
108 lines (107 loc) · 3.11 KB
/
webpack.common.app.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
103
104
105
106
107
108
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
const { merge } = require('webpack-merge');
const commonConfig = require('./webpack.common');
require('dotenv-defaults').config({
path: './.env',
encoding: 'utf8',
defaults: './.env.defaults'
});
module.exports = () =>
merge(commonConfig(), {
entry: {
popup: path.join(__dirname, 'src/index-popup.tsx'),
options: path.join(__dirname, 'src/index-options.tsx'),
dappConnector: path.join(__dirname, 'src/index-dapp-connector.tsx'),
['trezor-content-script']: path.join(__dirname, 'src/lib/scripts/trezor/trezor-content-script.ts'),
['trezor-usb-permissions']: path.join(__dirname, 'src/lib/scripts/trezor/trezor-usb-permissions.ts')
},
experiments: {
syncWebAssembly: true
},
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1,
modules: true
}
}
],
include: /\.module\.css$/
},
{
// Review: why are there 2 loaders with exactly the same 'test' for css?
test: /\.css$/,
use: ['style-loader', 'css-loader'],
exclude: /\.module\.css$/
},
{
exclude: /node_modules/,
test: /\.scss$/,
use: [
'style-loader', // Creates style nodes from JS strings
'css-loader', // Translates CSS into CommonJS
'sass-loader' // Compiles Sass to CSS
]
},
{
test: /^[.]*(?!.*\.component\.svg$).*\.svg*$/,
use: 'file-loader'
},
{
test: /component\.svg(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: '@svgr/webpack',
options: {
icon: true
}
}
]
},
{
test: /\.(eot|otf|ttf|woff|woff2|gif|png|webm)$/,
loader: 'file-loader'
},
{
test: /\.txt$/i,
loader: 'raw-loader'
}
]
},
plugins: [
new CopyPlugin({
patterns: [
{ from: 'src/assets/branding/*.png', to: '../[name][ext]' },
{ from: 'src/assets/html/trezor-usb-permissions.html', to: '../[name][ext]' }
]
}),
new HtmlWebpackPlugin({
filename: '../popup.html',
template: 'src/assets/html/popup.html',
chunks: ['popup'],
alwaysWriteToDisk: true
}),
new HtmlWebpackPlugin({
filename: '../app.html',
template: 'src/assets/html/app.html',
chunks: ['options'],
alwaysWriteToDisk: true
}),
new HtmlWebpackPlugin({
filename: '../dappConnector.html',
template: 'src/assets/html/popup.html',
chunks: ['dappConnector'],
alwaysWriteToDisk: true
}),
new HtmlWebpackHarddiskPlugin()
]
});