-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack_common.js
131 lines (127 loc) · 3.74 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const webpack = require('webpack');
const path = require('path');
const dotenv = require('dotenv');
const { gitDescribeSync } = require('git-describe');
const HtmlWebpackPlugin = require('html-webpack-plugin');
dotenv.config();
const gitInfo = gitDescribeSync();
const SRC_DIR = path.resolve(__dirname, 'src');
module.exports = {
entry: {
app: SRC_DIR + '/demo/index.tsx'
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html',
inject: true
})
],
resolve: {
extensions: ['.js', '.ts', '.tsx', '.scss', '.css']
},
module: {
rules: [
{
test: /\.worker\.ts$/,
use: [
{
loader: 'worker-loader',
options: {
inline: true
}
}
]
},
{
test: /\.(tsx|ts|js)$/,
loader: 'awesome-typescript-loader',
include: [path.join(__dirname, "src")]
},
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader"
},
{
// Css files in src/app/ are modular (module: true in the css-loader config)
// This means that the class names are prefixed and suffixed with a hash to make them scoped
test: /\.(scss|css)$/,
exclude: [
path.join(__dirname, 'src', 'css'),
path.join(__dirname, 'src', 'scss'),
],
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[name]__[local]--[hash:base64:5]'
}
},
{
loader: 'sass-loader'
}
]
},
{
// Css files that are not in src/app/ are not modular, so the css classes not prefixed or suffixed
test: /\.(scss|css)$/,
exclude: [
path.join(__dirname, 'src', 'app')
],
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
importLoaders: 1,
}
},
{
loader: 'sass-loader'
},
]
},
{
test: /\.(png|jpg|jpeg)$/,
loader: 'file-loader',
options: {
name: 'images/[name].[ext]',
// limit: 9999999
}
},
{
test: /\.(svg)$/,
loader: 'url-loader',
options: {
name: 'images/[name].[ext]',
limit: 999999999
}
},
{
test: /\.(woff|woff2|eot|ttf)$/,
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]',
// limit: 999
}
}
]
},
node: {
fs: 'empty',
child_process: 'empty'
},
optimization: {
splitChunks: {
cacheGroups: {
commons: { test: /[\\/]node_modules[\\/]/, name: "vendors", chunks: "all" }
}
}
},
};