-
-
Notifications
You must be signed in to change notification settings - Fork 121
errors cause webpack to not build #23
Comments
Please share your webpack config.
|
Btw jsx-loader is useless since babel handle it.
|
'use strict'
var webpack = require('webpack')
var path = require('path')
//put environment specific settings in here, to be used in the client
var config = require('./app-config.js')
var definePlugin = new webpack.DefinePlugin({
CONFIG: JSON.stringify(config)
})
var base_webpack_config = {
debug: true,
entry: [
"./app/js/main.js",
],
output: {
path: "./public/build/",
filename: "bundle.js",
publicPath: "/build/"
},
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules|bower_components/, loaders: ["babel-loader", "eslint-loader"]},
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" },
{ test: /\.scss$/, loader: "style!css!sass?outputStyle=expanded&" +
"includePaths[]=" + (path.resolve(__dirname, "./node_modules"))
},
{ test: /\.css$/, loader: "style!css"},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file?hash=sha512&digest=hex&name=[hash].[ext]',
'image?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
},
]
},
plugins: [
new webpack.NoErrorsPlugin(),
definePlugin,
],
eslint: {
//reporter: require("eslint-friendly-formatter"),
quiet: true,
failOnError: false,
failOnWarning: false,
emitError: false,
emitWarning: false
}
}
var dev_config = function() {
console.log("using dev webpack.config")
base_webpack_config.entry.unshift(
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server'
)
base_webpack_config.module.loaders.push(
{ test: /\.jsx$/, exclude: /node_modules|bower_components/, loaders: ["react-hot", "jsx-loader", "babel-loader", "eslint-loader"]}
)
return base_webpack_config
}
var staging_config = function() {
console.log("using staging webpack.config")
base_webpack_config.module.loaders.push(
{ test: /\.jsx$/, exclude: /node_modules|bower_components/, loaders: ["jsx-loader", "babel-loader", "eslint-loader"]}
)
return base_webpack_config
}
module.exports = process.env.NODE_ENV === 'staging' ? staging_config() : dev_config() |
Any suggestions? Would really love to use as part of our build process. |
Even with errors/warnings emitted, webpack should be able to build (even if you see some errors reporter, it's just "visual" errors_). According to the purpose of the loader, you should use it with default settings (or maybe just change the formatter (reporter). Sorry you must have something else breaking your build. Here is an example of build that is actually creating the expected file: |
Just to be sure, the source of this loader is simple enough for you to take a quick look in |
Yes, that's how I understand it as well. As soon as I remove eslint-loader from the loaders, everything builds fine. |
Can you take a quick look in the file I mention & tell me which one break the build ? Is it the |
I see that your are using |
I tracked down the issue.
So it looks like webpack will fail the build if webpack.emitError has any messages. I believe this line is supposed to overwrite that setting:
But by default webpack.options.eslint.options.emitError and webpack.options.eslint.options.emitWarning are not set. So emitError is the active emitter. I was able to fix the problem by explicitly setting emitWarning = true in the config. |
And you were right, it looks like the culprit is the NoErrorsPlugin, which I think many people will be using. I think the best bet is to set options.emitWarning = true by default. |
Yes, I will change default options if more people complains. Thanks for your investigation with me. |
FWIW I wanted to allow builds to be created during development, even with linting warnings/errors. It took a while to understand the settings required. Especially confusing was that using the NoErrorsPlugin was causing the build to not be created on linting errors. This seems backwards and I'm still no sure why this is the case. Removing the plugin and setting It would be nice if warnings/errors could be reported in tact, styled accordingly in the console and the build could also still complete. Though, it is working. Thanks for the contribution to open source. |
@levithomason what you are asking is a webpack change. This loader uses webpack emitWarning/emitError methods and cannot control in browser output. |
Thanks for the clarification. Will let it be. I got this working for our flow by treating Webpack's lint as a convenience only and implenting a separate gulp lint task for tests and the build. |
I know that we are having a similar problem, and are considering moving to only have the linter run through .git-hooks and removing eslint from our webpack build. |
Like I said, you can use But keep in mind that both error and warning are blocking hot update when |
Also, if you don't want this loader to report anything that might prevent the build from being made, just don't use this loader 🙃! |
Sounds good, thank @MoOx |
In case you want Webpack [latest] to detect errors/warnings but should still be able to build (but with warnings), do the ff:
Reference here |
With Webpack 4.2 just
works for me. |
I'm not sure if this is webpack related, or if I'm doing something wrong, but Here's my configuration:
Am I missing or misunderstanding something basic about what an error is, or in what circumstances will this fail? Happening for |
I have failOnError and failOnWarning set to false, but when the eslint loader detects errors/warnings, my bundle.js never gets created. My loaders look like this:
{ test: /.jsx$/, exclude: /node_modules|bower_components/, loaders: ["react-hot", "jsx-loader", "babel-loader", "eslint-loader"]}
The text was updated successfully, but these errors were encountered: