-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathwebpack.config.js
85 lines (82 loc) · 2 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
85
/*
* @Author: fang.yang
* @Date: 2019-10-31 17:27:39
* @Description [webpack basic config]
*/
const path = require('path');
const argv = require('yargs').argv;
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackBundleAnalyzer = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const modeConfig = env => require(`./build-utils/webpack.${env}`)(env);
const resolve = dir => path.resolve(__dirname, dir);
const { mode } = argv.env;
module.exports = () => {
return webpackMerge(
{
entry: {
'taro-designer': './public/index.js'
},
resolve: {
alias: {
'@utils': resolve('./src/utils'),
'@components': resolve('./src/components'),
'@container': resolve('./src/container')
},
modules: [resolve(__dirname, './src'), resolve(__dirname, './demo'), resolve('./node_modules')],
extensions: ['.js']
},
resolveLoader: {
moduleExtensions: ['-loader']
},
externals: {
axios: 'axios',
react: 'React',
'react-dom': 'ReactDOM',
'react-router-dom': 'ReactRouterDOM',
classnames: 'classNames',
mobx: 'mobx',
'mobx-react': 'mobxReact',
'cloud-react': 'CloudReact'
},
module: {
rules: [
{
test: /\.js$/,
exclude: [resolve('./node_modules')],
use: ['babel', 'eslint']
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url',
options: {
limit: 10000,
name: '[name]-[hash:7].[ext]'
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url',
options: {
limit: 10000,
name: '[name]-[hash:7].[ext]'
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'public/index.html',
minify: false,
chunks: ['vendors', 'taro-designer']
}),
// 分析打包大小问题
// new WebpackBundleAnalyzer(),
new webpack.ProgressPlugin()
]
},
modeConfig(mode)
);
};