question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

After ejecting, unsure of how to add Bourbon / Neat to webpack

See original GitHub issue

I am migrating an existing, server-rendered front-end to a React app. Woo! 🎉

It’s my first pure javascript front-end, so I’m a little rusty with things like webpack. I need to bring over Bourbon and Neat which I previously setup in Brunch, so I understand the necessity for include paths etc.

After ejecting, I made the following modifications…

package.json

"devDependencies": {
    ...
    "bourbon": "^4.2.7",
    "bourbon-neat": "^1.8.0",
    ...
}

config/paths.js

// config after eject: we're in ./config/
module.exports = {
  ...
  appSrc: resolveApp('src'),
  bourbon: require("bourbon").includePaths,
  bourbonNeat: require("bourbon-neat").includePaths,
  ...
};

config/webpack.config.dev.js (after also installing node-sass which is working great)

// SASS compatibility!
{
  test: /\.scss/,
  include: [
    paths.bourbon,
    paths.bourbonNeat,
    paths.appSrc
  ],
  loaders: ["style", "css", "sass"]
},

After this, it’s my understanding that simply @import "bourbon" from App.scss should work, but I’m getting.

Failed to compile.

Error in ./src/App.scss
Module build failed:
@import "bourbon";
^
      File to import not found or unreadable: bourbon
Parent style sheet: stdin

Does anyone see where I might be going wrong?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
lukerollanscommented, Oct 4, 2016

After a tiny bit more research I was able to solve it myself. I realised I needed to path the include paths to node-sass, not the loader (which I now understand is a different thing).

Here is what cleared it up for me https://github.com/jtangelder/sass-loader#sass-options

Hopefully this helps someone else in the future 🎉

2reactions
lukerollanscommented, Jan 17, 2017

@designbyadrian Yes they do 😃

webpack.config.dev.js

  sassLoader: {
    includePaths: [
      paths.bourbon,
      paths.bourbonNeat
    ]
  },

config/paths.js (How I do it, anyway)

// config after eject: we're in ./config/
module.exports = {
  appBuild: resolveApp('build'),
  appPublic: resolveApp('public'),
  appHtml: resolveApp('public/index.html'),
  appIndexJs: resolveApp('src/index.js'),
  appPackageJson: resolveApp('package.json'),
  appSrc: resolveApp('src'),
  bourbon: require("bourbon").includePaths,
  bourbonNeat: require("bourbon-neat").includePaths,
  testsSetup: resolveApp('src/setupTests.js'),
  appNodeModules: resolveApp('node_modules'),
  ownNodeModules: resolveApp('node_modules'),
  nodePaths: nodePaths
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Neat (Bourbon) compilation issues with webpack.config.js
I'm currently trying to compile my _layout.sass file into CSS and I have dependencies on Bourbon and Neat. My current _layout.sass is this:...
Read more >
Adding Webpack with Hot Module Replacement to speed up ...
Adding Webpack with Hot Module Replacement to speed up Redux/React/Sass development within ... including the correct hookups with bourbon and bourbon neat.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found