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

Support for sass-loader 8.0.0 #654

Closed
Atlanta opened this issue Oct 18, 2019 · 4 comments
Closed

Support for sass-loader 8.0.0 #654

Atlanta opened this issue Oct 18, 2019 · 4 comments

Comments

@Atlanta
Copy link

Atlanta commented Oct 18, 2019

OS : WSL Ubuntu 18.04
webpack-encore : 0.28.0

Since I upgraded my package.json, sass-loader was updated to 8.0.0, and I get the following warning running yarn encore dev :

Running webpack ...

  WARNING   Webpack Encore requires version ^7.0.1 of sass-loader. Your version 8.0.0 is too new. The related feature *may* still work properly. If you have issues, try downgrading the library, or upgrading Encore.

My webpack.config.js :

var Encore = require('@symfony/webpack-encore');

Encore
    .setOutputPath('public/build/')
    .setPublicPath('/build')

    // some javascript entries
    // ...

    .enableSingleRuntimeChunk()
    .enableSourceMaps(!Encore.isProduction())
    .enableVersioning(Encore.isProduction())

    .enableSassLoader((options) => {
        options.sourceMap = true;
        options.sassOptions = {
            outputStyle: 'compressed',
            sourceComments: !Encore.isProduction(),
        };
    }, {})

    .autoProvidejQuery()
    .configureBabel(function (babelConfig) {
        babelConfig.plugins.push('@babel/plugin-proposal-class-properties');
    })
    .enableReactPreset()
    .copyFiles({
        from: './assets/images',
        to: 'images/[path][name].[ext]',
    })
    .copyFiles({
        from: './assets/svg',
        to: 'svg/[path][name].[ext]',
    })
;

module.exports = Encore.getWebpackConfig();

Could be integrated to PR #645

@stof
Copy link
Member

stof commented Oct 18, 2019

this does not belong to #645, as sass-loader 8 is still for webpack 4, not for webpack 5.

@wrufeger
Copy link

wrufeger commented Jan 3, 2020

sass-loader 8 uses sassOptions object as you provided already in webpack config. To use it with webpack-encore 0.28.0 you may use the following dirty hack in webpack-encore/lib/loaders/sass.js.
Replace
const config = Object.assign({}, { // needed by the resolve-url-loader sourceMap: (true === webpackConfig.sassOptions.resolveUrlLoader) || webpackConfig.useSourceMaps, // CSS minification is handled with mini-css-extract-plugin outputStyle: 'expanded' });
with
const config = {sassOptions: Object.assign({}, { // needed by the resolve-url-loader sourceMap: (true === webpackConfig.sassOptions.resolveUrlLoader) || webpackConfig.useSourceMaps, // CSS minification is handled with mini-css-extract-plugin outputStyle: 'expanded' })};

@hacfi
Copy link

hacfi commented Jan 23, 2020

My current workaround for this is editing webpack.config.js:

    .enableSassLoader((options) => {
        options.sourceMap = true;
        options.sassOptions = {
            outputStyle: options.outputStyle,
            sourceComments: !Encore.isProduction(),
        };
        delete options.outputStyle;
    }, {})

@b1rdex
Copy link

b1rdex commented May 19, 2020

Fixed in #758

@stof stof closed this as completed May 19, 2020
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

Successfully merging a pull request may close this issue.

5 participants