-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathwebpack.config.js
executable file
·84 lines (83 loc) · 2.43 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
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
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;
module.exports = {
mode: 'none',
devtool: 'source-map',
entry: {
tree: './src/index.js',
'tree.min': './src/index.js',
},
output: {
filename: '[name].js',
libraryExport: 'default',
library: 'Tree',
libraryTarget: 'umd',
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.less$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: [
require('postcss-import'),
require('autoprefixer'),
],
},
},
'less-loader',
],
},
],
},
optimization: {
minimize: true,
minimizer: [
new UglifyJSPlugin({
include: /\.min\.js$/,
cache: true,
parallel: true,
sourceMap: true,
uglifyOptions: {
compress: {
warnings: false,
comparisons: false,
drop_console: true,
},
mangle: {
safari10: true,
},
output: {
comments: false,
ascii_only: true,
},
},
}),
],
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new OptimizeCSSAssetsPlugin({
assetNameRegExp: /\.min\.css$/,
}),
new webpack.BannerPlugin(
'treejs\n@version 1.8.0\n@see https://github.com/daweilv/treejs'
),
new BundleAnalyzerPlugin({ analyzerMode: 'static' }),
],
};