catamphetamine / webpack-isomorphic-tools

Server-side rendering for your Webpack-built applications (e.g. React)
MIT License
1.25k stars 48 forks source link

Ability to ignore warnings / errors #149

Closed RaulTsc closed 6 years ago

RaulTsc commented 6 years ago

Hey, great framework! :)

Would it be possible to add the ability to ignore warnings/errors?

Thanks!

catamphetamine commented 6 years ago

Be more specific

RaulTsc commented 6 years ago

I am currently able to disable debugging with debug: false (which defaults to false).

But I also want to disable warning/error logging. For example when running a node app like

const WebpackIsomorphicTools = require('webpack-isomorphic-tools');
new WebpackIsomorphicTools(require('./src/webpack-isomorphic-tools'))
  .server(rootDir, () => { require('./src/server'); });

I will see a lot of error: asset not found (because it cannot find the key in webassets.json). But I don't have webpack as a dependency and webassets.json is just there so that the server starts (If not it will be stuck saying Waiting for first webpack build.

My specific use case is this:

I have a common-react-components library that I use for the web app but I also want to use components from there in my pdf generation service. In order to do that, I import the components there, and do React.renderToString() to get the html that I pass to wkhtmltopdf to get the pdf.

So in order to not see the errors I need to do this

"{PATH}/Grid/GridList/GridList.scss": {},
    "{PATH}/Grid/GridItem/GridItem.scss": {},
    "{PATH}/Separator/Separator.scss": {},
    "{PATH}/ResponsiveImage/ResponsiveImage.scss": {},
    "{PATH}/Links/Links.scss": {}

Does that make sense?

Thanks!

RaulTsc commented 6 years ago

The entire webpack-assets.json that I use so that I don't have an extra compile step with webpack which I don't need.

{
  "javascript": {
    "main": ""
  },
  "styles": {},
  "assets": {
    "{PATH}/Grid/GridList/GridList.scss": {},
    "{PATH}/Grid/GridItem/GridItem.scss": {},
    "{PATH}/Separator/Separator.scss": {},
    "{PATH}/ResponsiveImage/ResponsiveImage.scss": {},
    "{PATH}/Links/Links.scss": {}
  },
  "webpack": {
    "version": "3.7.1"
  }
}
catamphetamine commented 6 years ago

If it outputs errors then it means that these styles are required somewhere in your components. You're saying that you don't need styles to generate the PDF. Why are you using webpack-isomorphic-tools then.

RaulTsc commented 6 years ago

I cannot require the needed components (which don't use scss) because it throws an error that it can't parse scss. Even though I use the full part for the import, I don't import for a common index.ts for example.

catamphetamine commented 6 years ago

In that case you should play with the CSS file type settings: https://github.com/catamphetamine/webpack-isomorphic-tools#configuration E.g. set path to return /empty and add /empty to your webpack-assets.json.