-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.base.config.js
95 lines (92 loc) · 1.96 KB
/
webpack.base.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
95
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const Dotenv = require('dotenv-webpack');
const webpack = require('webpack'); // eslint-disable-line import/no-extraneous-dependencies
const config = require('./config');
const paths = require('./webpack/paths');
const useFonts = [
{
loader: 'url-loader',
options: {
limit: 512,
name: 'assets/fonts/[name].[ext]',
publicPath: config.appPublicPath,
},
},
];
const useImages = [
{
loader: 'url-loader',
options: {
limit: 512,
name: 'assets/images/[name].[ext]',
publicPath: config.appPublicPath,
},
},
];
module.exports = {
context: paths.root,
module: {
rules: [
{
test: /\.(woff|woff2|ttf|eot|otf)$/,
use: useFonts,
},
{
test: /fonts\/.*\.svg/,
use: useFonts,
},
{
test: /\.svg$/,
use: [
...useImages,
{
loader: 'svgo-loader',
options: {
plugins: [
{ cleanupIDs: false },
{ removeAttrs: { attrs: '(data-name)' } },
],
},
},
],
},
{
test: /\.(jpe?g|png|gif)$/,
use: useImages,
},
],
},
output: {
filename: '[name].js',
path: paths.build,
publicPath: config.appPublicPath,
},
resolve: {
modules: ['node_modules', 'src'],
alias: {
'@Config': paths.config,
'@Root': paths.root,
},
extensions: ['.json', '.js', '.jsx'],
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser',
}),
new CopyPlugin({
patterns: [
{
from: path.resolve(paths.src, 'assets/favicon/'),
to: path.resolve(paths.build, 'assets/favicon/'),
},
],
}),
new Dotenv({
path: path.resolve(paths.root, '.env'),
safe: false,
silent: true,
systemvars: true,
}),
],
};