happypack icon indicating copy to clipboard operation
happypack copied to clipboard

SASS loader error if import css file in sass

Open KMBaby-zyl opened this issue 8 years ago • 3 comments

my config

` {

loaders: [{ loader: ExtractTextPlugin.extract('style', 'happypack/loader?id=sass') }],

plugins: [new HappyPack({

 id: 'sass',

 loaders: [ 'css-loader?sourceMap&-convertValues', 'sass-loader?sourceMap' ] })]

} `

in .scss file

@import '../img_sprites/css/webim.css';

error info

ERROR in ./webim/im.scss Module build failed: ModuleParseError: Module parse failed: /Users/zhangyili/workspace/iwjw-pc/img_sprites/css/webim.css Unexpected token (1:0) You may need an appropriate loader to handle this file type. SyntaxError: Unexpected token (1:0)

if i delete @import '../img_sprites/css/webim.css';

it works

KMBaby-zyl avatar Oct 08 '16 11:10 KMBaby-zyl

I have the same thing with less, it all works when i have the less-loader without happypack. Using version 2.2.1. This is my config

module.loaders:{
    {
        test: /\.css$/,
        include: resourceIncludes,
        loader: ExtractTextPlugin.extract('style-loader', 'happypack/loader?id=css')
      }, {
        test: /\.(less)$/,
        include: resourceIncludes,
        loader: ExtractTextPlugin.extract('style-loader', 'happypack/loader?id=less')
    }
}
plugins:[
createHappyPlugin('less', ['css-loader!less-loader']),    
createHappyPlugin('css', ['css-loader'])
]

function createHappyPlugin(id, loaders) {
  return new HappyPack({
    id: id,
    loaders: loaders,
     threadPool: happyThreadPool,
    cache: true,
    verbose: true,
  });
}

crooy avatar Oct 25 '16 20:10 crooy

I solved this problem as follow

module: {
        loaders: [
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract("style", "happypack/loader?id=css")
            },

            {
                test: /\.scss/,
                loader: ExtractTextPlugin.extract("style", 'css?minimize', "happypack/loader?id=scss")
            },
            {
                test: /\.js$/,
                loader: 'happypack/loader?id=js',
                exclude: /node_modules/,
                include: __dirname,
            }
        ]
    },
    plugins: [
        createHappyPlugin('css', ['css?minimize']),
        createHappyPlugin('scss', ['sass'])
 ]

Tankpt avatar Nov 16 '16 10:11 Tankpt

What's the status on this? Is it fixed by the 4.0.0 release?

amireh avatar Oct 22 '17 12:10 amireh