amireh / happypack

Happiness in the form of faster webpack build times.
MIT License
4.24k stars 124 forks source link

Less plugins throw error #187

Open zp1996 opened 7 years ago

zp1996 commented 7 years ago

Hi, when i use happypack with less, such as:

var createHappyPlugin = function (id, loaders) {
    return new HappyPack({
        id: id,
        loaders: loaders,
        threadPool: HappyPack.ThreadPool({ size: os.cpus().length }),
        verbose: true
    });
};

create like:

        createHappyPlugin(
            'less',
            [
                'style-loader',
                {
                    loader: 'css-loader',
                    options: {
                        modules: true,
                        importLoaders: 1,
                        localIdentName: '[path][name]__[local]--[hash:base64:5]'
                    }
                },
                'postcss-loader',
                {
                     loader: 'less-loader',
                     strictImports: true,
                     options: {
                         plugins: [
                             new LessPluginFunctions()
                         ]
                     }
                }
            ]
        ),

it will throw error:

TypeError: plugin.install is not a function
amireh commented 7 years ago

It's postcss not less: you need to configure postcss in a separate file and point to that. See https://github.com/amireh/happypack/issues/84#issuecomment-257366444 for more information.

Edit I see you're not actually using postcss-loader, but regardless it's the same thing; you can't serialize functions, so you need to move any config that instantiates objects to a different file (and the loader must support loading config from files like babel and postcss do.)