-
Notifications
You must be signed in to change notification settings - Fork 109
/
webpack.base.js
82 lines (79 loc) · 2.55 KB
/
webpack.base.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
/* eslint import/no-extraneous-dependencies: [2, {"devDependencies": true}] */
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const webpack = require('webpack');
const QUERY = {
name: '[name].[hash].[ext]',
};
module.exports = {
resolve: {
modules: [
'node_modules',
path.join(process.cwd(), 'node_modules'),
],
extensions: ['.js', '.ts', '.tsx'],
},
module: {
rules: [
{
test: /\.(t|j)sx?$/,
loader: require.resolve('ts-loader'),
exclude: /node_modules/,
options: {
transpileOnly: true,
},
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: require.resolve('file-loader'),
options: { mimetype: 'application/font-woff', ...QUERY },
},
{
test: /\.(ttf)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: require.resolve('file-loader'),
options: { mimetype: 'application/octet-stream', ...QUERY },
},
{
test: /\.(eot)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: require.resolve('file-loader'),
},
{
test: /\.(jpe?g)$/i,
loader: require.resolve('file-loader'),
options: { mimetype: 'image/jpeg', ...QUERY },
},
{
test: /\.(gif)$/i,
loader: require.resolve('file-loader'),
options: { mimetype: 'image/gif', ...QUERY },
},
{
test: /\.(png)$/i,
loader: require.resolve('file-loader'),
options: { mimetype: 'image/png', ...QUERY },
},
{
test: /\.(svg)$/i,
loader: require.resolve('file-loader'),
options: { mimetype: 'image/svg+xml', ...QUERY },
},
{
test: /\.css$/,
use: [
require.resolve('style-loader'),
require.resolve('css-loader'),
require.resolve('postcss-loader'),
],
},
],
},
plugins: [
new webpack.ProvidePlugin({
React: 'react',
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.HOT_LOADER': process.env.HOT_LOADER,
}),
],
};