UNPKG

2.41 kBJavaScriptView Raw
1const path = require('path');
2const merge = require('webpack-merge');
3const baseConfig = require('./webpack.base');
4const notifier = require('node-notifier');
5const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
6const port = 3000;
7
8module.exports = merge(baseConfig, {
9 mode: 'development',
10 entry: {
11 kview: './examples/index'
12 },
13 devServer: {
14 contentBase: path.resolve(process.cwd(), './public'),
15 compress: true,
16 hot: true,
17 overlay: true,
18 quiet:true,
19 port,
20 },
21 plugins: [
22 new FriendlyErrorsWebpackPlugin({
23 compilationSuccessInfo: {
24 messages: [`Your application is running here: http://localhost:${port}`],
25 notes:[`Note that the development build is not optimized. \n To create a production build, run ' npm run build '.`],
26 },
27 onErrors (severity, errors) {
28 // You can listen to errors transformed and prioritized by the plugin
29 // severity can be 'error' or 'warning'
30 if (severity !== 'error') {
31 return;
32 }
33 const error = errors[0];
34 notifier.notify({
35 title: "Webpack error",
36 message: severity + ': ' + error.name,
37 subtitle: error.file || '',
38 });
39 },
40 clearConsole: true,
41 }),
42 ],
43 optimization: {
44 splitChunks: {
45 chunks: 'all',
46 cacheGroups: {
47 vendors: {
48 test: /[\\/]node_modules[\\/]/, // 匹配node_modules目录下的文件
49 priority: -10
50 },
51 elementBase: {
52 test: (module) => {
53 return /element-ui/.test(module.context);
54 },
55 name: "elementBase",
56 priority: 10,
57 },
58 default: {
59 minChunks: 2,
60 priority: -20,
61 reuseExistingChunk: true
62 }
63 }
64 },
65 minimize: false,
66 },
67 externals: {
68 'vue': 'Vue',
69 'vue-router': 'VueRouter',
70 'element-ui': 'ELEMENT',
71 },
72})
\No newline at end of file