当我运行linting时,如果出现问题我会收到错误,否则我不会得到lint i执行的通知。在插件或加载器执行后是否可以添加日志消息?
在我的特定情况下,我想在" StyleLintPlugin" -plugin和" tslint" -loader之后添加日志消息。请参阅下面的Webpack配置。
import path from 'path';
import StyleLintPlugin from 'stylelint-webpack-plugin';
module.exports = {
entry: path.resolve(__dirname, "js/index"),
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "build"),
publicPath: '/'
},
target: 'web',
watch: true, //Rebuild when file is changed
devtool: 'source-map', //Let us debug the code without being modified
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.ts', '.js', '.css', '.scss']
},
plugins: [
//Used to lint sass files
new StyleLintPlugin({
configFile: '.stylelintrc',
context: undefined,
files: ['**/*.s?(a|c)ss'],
failOnError: true,
quiet: false
}),
],
module: {
preLoaders: [
{
test: /\.ts$/,
exclude: /node_modeules/,
loader: 'tslint'
}
],
loaders: [
{
test: /\.ts(x?)$/,
exclude: /node_modeules/,
loader: 'babel-loader!ts-loader'
},
{
test: /\.css$/,
exclude: /node_modeules/,
loader: "style-loader!css-loader"
},
{
test: /\.scss$/,
exclude: /node_modeules/,
loader: "style-loader!css-loader!sass-loader"
}
],
},
tslint: {
emitErrors: true,
failOnHint: true
}
}
答案 0 :(得分:0)
进行Webpack构建以读取隐藏的错误或获取完整的日志(而不是“ npm run dev”,请尝试“ npm run build”)。
开发服务器构建过程中隐藏的错误是WebPack中已知的但很少讨论且令人讨厌的错误,已经存在了多年。
您可以做一个完整的构建,以在错误隐蔽的情况下查看错误。
修复错误后,您可以直接返回“ npm run dev”。