Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work for scss files #3

Open
raderj89 opened this issue Jul 22, 2019 · 4 comments
Open

Doesn't work for scss files #3

raderj89 opened this issue Jul 22, 2019 · 4 comments

Comments

@raderj89
Copy link

raderj89 commented Jul 22, 2019

Similar problem to #1 but the suggested solution doesn't work for me.

My project uses scss. In my webpack config, I've got:

const path = require('path');

module.exports = {
  // other configs...
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: [
          {
            loader: 'style-loader',
          },
          {
            loader: 'css-loader',
          },
          {
            loader: 'sass-loader',
          },
          {
            loader: 'cssimportant-loader',
          }
        ],
      },
    ],
  },
};

Webpack fails to compile with this error:

ERROR in ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/lib/loader.js!./node_modules/cssimportant-loader!./src/components/index.scss
Module build failed: Error: undefined:24:3: missing '}'

It looks like it's trying to parse the scss and not the compiled css.

I even switched the order of sass-loader and css-loader but that didn't work either.

Any suggestions?

@officert
Copy link
Owner

maybe try changing the order, since it expects CSS and not Sass:

const path = require('path');

module.exports = {
  // other configs...
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: [
          {
            loader: 'style-loader',
          },
          {
            loader: 'cssimportant-loader',
          },
          {
            loader: 'css-loader',
          },
          {
            loader: 'sass-loader',
          }
        ],
      },
    ],
  },
};

@raderj89
Copy link
Author

raderj89 commented Aug 13, 2019

same issue after doing the ordering you suggested:

ERROR in ./node_modules/cssimportant-loader!./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/lib/loader.js!./src/components/index.scss
Module build failed: Error: undefined:3:52: property missing ':'
    at error (/Users/jaredrader/src/github.com/apps/chat-widget/node_modules/css/lib/parse/index.js:62:15)
    at declaration (/Users/jaredrader/src/github.com/apps/chat-widget/node_modules/css/lib/parse/index.js:224:33)
    at declarations (/Users/jaredrader/src/github.com/apps/chat-widget/node_modules/css/lib/parse/index.js:253:19)
    at rule (/Users/jaredrader/src/github.com/apps/chat-widget/node_modules/css/lib/parse/index.js:561:21)
    at rules (/Users/jaredrader/src/github.com/apps/chat-widget/node_modules/css/lib/parse/index.js:118:70)
    at stylesheet (/Users/jaredrader/src/github.com/apps/chat-widget/node_modules/css/lib/parse/index.js:81:21)
    at Object.module.exports [as parse] (/Users/jaredrader/src/github.com/apps/chat-widget/node_modules/css/lib/parse/index.js:565:20)
    at Object.module.exports (/Users/jaredrader/src/github.com/apps/chat-widget/node_modules/cssimportant-loader/index.js:24:19)

@raderj89
Copy link
Author

This worked for me.... I copied the contents of cssimportant loader's index.js file into my project, added the css package and added it as a transform option:

      {
        test: /\.scss$/,
        use: [
          {
            loader: 'style-loader',
            options: {
              transform: './css-transform.js'
            }
          },
          {
            loader: 'css-loader',
          },
          {
            loader: 'sass-loader',
          },
        ],
      },

@hewenguang
Copy link

hewenguang commented Nov 20, 2020

My configuration file is fine, it seems the order is important

[{ loader: MiniCssExtractPlugin.loader, }, { loader: 'css-loader', }, { loader: 'cssimportant-loader', }, { loader: 'sass-loader', }]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants