Vuepress: Sass imports of node_modules do not work when building

Created on 21 Apr 2018  路  6Comments  路  Source: vuejs/vuepress

  • Your OS: Windows 10
  • Node.js version: 8.10.0
  • VuePress version: 0.6.1
  • Browser version: Chrome 65
  • Is this a global or local install?: local
  • Which package manager did you use for the install?: yarn

Bug:
If you import sass files from a node_module it will work on the dev server, but it fails when building the project.

Steps to reproduce:

  1. clone repo: https://github.com/peXed/vuepress-test
  2. run yarn docs:build and you will get the following error:
    File to import not found or unreadable: ~bulma.
  3. run yarn docs:dev and everything will work as expected

Expected behavior:
Importing node_modules works when building the project as well.

bug

Most helpful comment

@ulivz unfortunatly, this is not fixing the issue.

The prefix ~ should be fine, because it tells Webpack that this is not a relative path (for more information see: https://github.com/webpack-contrib/sass-loader#imports).
With the prefix the import works great in development (without the prefix, you will get an error message).
But during the build process, the import is not working.
I guess this may be an webpack issue, not finding the node_modules anymore?

Can we reopen the issue?

All 6 comments

@ulivz - would you mind if I took a look at this?

You just used a wrong import path but didn't set any alias:

  @import "~bulma";

remove the ~ instead.

@ulivz unfortunatly, this is not fixing the issue.

The prefix ~ should be fine, because it tells Webpack that this is not a relative path (for more information see: https://github.com/webpack-contrib/sass-loader#imports).
With the prefix the import works great in development (without the prefix, you will get an error message).
But during the build process, the import is not working.
I guess this may be an webpack issue, not finding the node_modules anymore?

Can we reopen the issue?

Hey! This is still not fixed.
@ulivz look at the docs: https://github.com/webpack-contrib/sass-loader#imports
@import ~xxxx IS valid :)

Hmm facing the same issue now. Are there any solutions or any hints why this problem exists?

To give an idea about my actual problem, I have something like this in my enhanceApp.js file:

import './styles.sass'

export default ({
  Vue,
  options,
  router,
  siteData
}) => {

}

I added the node-sass and sass-loader packages to preprocess the sass. On running vuepress dev docs the sass rules are included, but on running vuepress build docs there are not.

i don鈥檛 want to use any framework integration or wrapper!
How to use material-components-web?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tinchox5 picture tinchox5  路  3Comments

cfjedimaster picture cfjedimaster  路  3Comments

kid1412621 picture kid1412621  路  3Comments

sankincn picture sankincn  路  3Comments

higuoxing picture higuoxing  路  3Comments