-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.common.js
97 lines (96 loc) · 2.48 KB
/
webpack.common.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
const path = require('path');
const isDebug = !process.argv.includes('--release');
const isVerbose = process.argv.includes('--verbose');
const isAnalyze = process.argv.includes('--analyze') || process.argv.includes('--analyse');
module.exports = {
context: path.join(__dirname, 'src'),
output: {
path: path.join(__dirname, 'www'),
filename: 'bundle.js',
publicPath: '/',
},
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.css', '.scss'],
modules: [path.join(__dirname, 'node_modules')],
},
module: {
rules: [
{
test: /\.(t|j)sx?$/,
exclude: /node_modules/,
use: {
loader: 'ts-loader',
},
},
{
enforce: 'pre',
test: /\.(t|j)s$/,
exclude: /node_modules/,
loader: 'source-map-loader',
},
{
test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
exclude: /node_modules/,
loader: 'file-loader',
query: {
name: isDebug ? '[path][name].[ext]?[hash:8]' : '[hash:8].[ext]',
},
},
{
test: /\.css$/,
use: [
{ loader: 'isomorphic-style-loader' },
{
loader: 'css-loader',
options: {
importLoaders: 1,
sourceMap: isDebug,
onlyLocals: true,
modules: {
localIdentName: isDebug ? '[name]-[local]-[hash:base64:5]' : '[hash:base64:5]',
},
},
},
],
},
{
test: /theme.scss$/,
use: [
{ loader: 'isomorphic-style-loader' },
{
loader: 'css-loader',
options: {
onlyLocals: true,
modules: {
localIdentName: '[local]',
},
sourceMap: true,
importLoaders: 2,
},
},
{ loader: 'sass-loader' },
],
},
{
test: /\.scss$/,
exclude: [/theme.scss$/],
use: [
{ loader: 'isomorphic-style-loader' },
{
loader: 'css-loader',
options: {
onlyLocals: true,
modules: {
localIdentName: isDebug ? '[name]_[local]_[hash:base64:3]' : '[hash:base64:4]',
},
sourceMap: true,
importLoaders: 2,
},
},
{ loader: 'sass-loader' },
],
},
],
},
};