forked from alibaba/butterfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
58 lines (57 loc) · 1.51 KB
/
webpack.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
let webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
mode: 'production',
performance: {
hints: false
},
entry: './index.js',
output: {
path: __dirname,
filename: 'dist/index.js',
libraryTarget: 'umd',
},
resolve: {
alias: {},
},
plugins: [
new MiniCssExtractPlugin({
filename: 'dist/index.css',
chunkFilename: '[id].css'
})
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'], //'env'--babel7中的es7语法编译插件
// plugins: ['transform-decorators-legacy', 'transform-class-properties', 'add-module-exports', 'transform-object-rest-spread'],
plugins: ['transform-es2015-modules-commonjs', '@babel/plugin-proposal-object-rest-spread', '@babel/plugin-proposal-class-properties']
}
}
}, {
test: /\.less$/,
use: [
MiniCssExtractPlugin.loader, {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "less-loader" // compiles Less to CSS
}]
}, {
test: /\.(woff|woff2|eot|ttf|otf|svg)$/,
use: {
loader: 'url-loader',
options: {
limit: 1024 * 200,
name: '[name].[ext]',
outputPath: '/dist/fonts/'
}
}
}
]
}
};