1 | const path = require('path');
|
2 | const merge = require('webpack-merge');
|
3 | const baseConfig = require('./webpack.base');
|
4 | const notifier = require('node-notifier');
|
5 | const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
|
6 | const port = 3000;
|
7 |
|
8 | module.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 |
|
29 |
|
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[\\/]/,
|
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 |