我看到错误消息 - 它是红色的 - 但我希望它返回一个非零退出代码,所以我知道它出错了。我错过了什么配置?我没有使用无错误插件
'use strict'
const webpack = require('webpack')
const path = require('path')
const babel_cache_path = require('../config/babel').cache_path
const port = require('../config').port
module.exports = {
entry: {
index: './client/index',
dev: [
'webpack-dev-server/client?http://localhost:' + (port + 1),
'webpack/hot/only-dev-server',
],
},
output: {
path: path.resolve('build'),
publicPath: 'http://localhost:' + (port + 1) + '/',
filename: '[name].js',
chunkFilename: '[id].[name].js',
},
plugins: [
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
}),
new webpack.HotModuleReplacementPlugin(),
// new webpack.NoErrorsPlugin(),
],
resolve: {
extensions: [
'',
'.js',
'.jsx'
]
},
module: {
loaders: [
// babel + jsx loader
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: [
`babel?cacheDirectory=${babel_cache_path}`
]
},
// json loader
{
test: /\.json$/,
loaders: [
'json'
]
},
// css loader
{
test: /\.css$/,
loaders: [
'style',
'css?modules&sourceMap&importLoaders=1&localIdentName=[path][name]---[local]---[hash:base64:5]',
'postcss'
]
}
],
},
postcss () {
return require('postcss-jongleberry')({
minify: false
})
},
// no node builtins
node: false
}
答案 0 :(得分:3)
在配置中添加--bail
cli选项或bail: true
应返回有效的错误退出代码,但似乎有些人在webpack 1. *版本中遇到问题。
为此唯一目的创建了一个特定模块,webpack-fail-plugin
npm i webpack-fail-plugin
然后将其添加到您的webpack插件配置中。