catamphetamine / universal-webpack

Isomorphic Webpack: both on client and server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Resolving css node_modules

LukeSheard opened this issue · comments

I typically use normalize.css to reset styles in my apps, in the client config I can just add require('normalize.css') which runs fine, however in the server configuration it does not get parsed as it's seen as an external module which can just be "required", however this breaks the build. I've created a repo to illustrate the issue here: https://github.com/LukeSheard/universal-webpack-bug.

You'll see in server.js that we simply just have a require('normalize.css') statement still in the code, but this obviously fails when you run the build with

$PATH_TO_PROJECT/node_modules/normalize.css/normalize.css:13
html {
     ^
SyntaxError: Unexpected token { ...
/* unknown exports provided */
/* all exports used */
/*!********************************!*\
  !*** external "normalize.css" ***!
  \********************************/
/***/ function(module, exports) {

module.exports = require("normalize.css");

normalize.css package was marked as external and was not transpiled.
You can exclude packages and files from externals: see the README for exclude_from_externals

@halt-hammerzeit Thanks for the quick response, this was exactly what I was looking for.