-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.base.config.js
142 lines (140 loc) · 4.73 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
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
131
132
133
134
135
136
137
138
139
140
141
142
let path = require('path');
let webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = function (options) {
let {
cdn,
dist,
root,
src
} = options;
let publicPath = `${cdn}`;
let distPath = path.resolve(root, dist);
let def = {
mode: 'development',
entry: {
'form': path.resolve(root, src, 'index.tsx'),
},
output: {
path: distPath,
filename: '[name].js',
chunkFilename: '[name].chunk.js',
publicPath: publicPath,
// library: 'PropsEditor',
// libraryTarget: 'umd'
},
module: {
rules: [
// or any other compile-to-css language
{
test: /\.less$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
// you can specify a publicPath here
// by default it use publicPath in webpackOptions.output
publicPath
}
},
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: function () {
return [
require('autoprefixer')
];
}
}
}, {
loader: 'less-loader',
options: {
javascriptEnabled: true,
modifyVars: {
'@primary-color': '#FB7055',
'@border-radius-base': 0,
'@border-radius-sm ': 0
}
}
}
]
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
// you can specify a publicPath here
// by default it use publicPath in webpackOptions.output
publicPath
}
},
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: function () {
return [
require('autoprefixer')
];
}
}
}
]
},
{
test: /\.(js|jsx|ts|tsx)$/,
exclude: /(node_modules|bower_components)/,
use: [
{
loader: 'babel-loader'
}
]
},
{
test: /\.(jpg|png|gif)$/,
use: [{
loader: 'url-loader',
options: {
limit: 1,
name: 'img/[path][name].[ext]'
}
}]
},
{
test: /\.(eot|svg|ttf|woff)\??.*$/,
use: [{
loader: 'url-loader',
options: {
limit: 1,
name: 'iconfont/[name].[ext]'
}
}]
}
]
},
node: {
// Mock Node.js modules that Babel require()s but that we don't
// particularly care about.
fs: 'empty',
module: 'empty',
net: 'empty'
},
cache: true,
resolve: {
alias: {
'@': path.resolve(root, './src'),
},
extensions: ['.json', '.js', '.jsx','.ts','.tsx']
},
plugins: [
// new webpack.IgnorePlugin({
// resourceRegExp: /^\.\/locale$/,
// contextRegExp: /moment$/
// }),
]
};
return def;
};