const path = require('path'); const merge = require('webpack-merge'); const common = require('./webpack.common.config.js'); const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin', null, 2); const webpack_config = merge(common, { mode: 'development', output: { filename: 'js/[name].[hash:8].bundle.js', }, module: { rules: [ { test: /\.css$/, use: ['style-loader', 'css-loader', 'postcss-loader'], }, { test: /\.less$/, use: ['style-loader', 'css-loader', 'postcss-loader', 'less-loader'], }, ], }, devServer: { contentBase: path.resolve(__dirname, '../dist'), open: true, port: 9000, compress: true, hot: true, quiet: true, }, plugins: [ new HtmlWebpackPlugin({ template: 'public/index.html', inject: 'body', hash: false, }), new webpack.HotModuleReplacementPlugin(), new FriendlyErrorsWebpackPlugin({ // 运行成功 compilationSuccessInfo: { messages: ['You application is running here http://localhost:9000'], notes: [ 'Some additionnal notes to be displayed unpon successful compilation', ], }, // 运行错误 onErrors: function (severity, errors) { //您可以收听插件转换和优先级的错误 //严重性可以是'错误'或'警告' }, //是否每次编译之间清除控制台 //默认为true clearConsole: true, //添加格式化程序和变换器(见下文) additionalFormatters: [], additionalTransformers: [], }), ], }); module.exports = webpack_config;