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

How to add 'image-webpack-loader' to compress assets in CSS files ? #897

Open
Deejay-Ste opened this issue Feb 26, 2020 · 0 comments
Open

Comments

@Deejay-Ste
Copy link

Hi,
First of all thanks for this amazing tool !
But I struggle to add https://github.com/tcoopman/image-webpack-loader to compress the generated assets from my SCSS files.

I almost got it by it generate the files two times. Here's the webpackConfig part of my wpackio.project.js files :

webpackConfig: (config, merge, appDir, isDev) => {
  const svgs = /\.svg$/i;

  let { fileRulesNonStyle, fileRulesStyle } = getFileLoaderForJsAndStyleAssets(
    appDir,
    isDev
  );

  fileRulesNonStyle.use = [
    {
      loader: fileLoader,
      options: getFileLoaderOptions(appDir, isDev, false)
    },
    "image-webpack-loader"
  ];

  fileRulesStyle.use = [
    {
      loader: fileLoader,
      options: getFileLoaderOptions(appDir, isDev, true)
    },
    "image-webpack-loader"
  ];

  const override = {
    module: {
      rules: [
        {
          test: svgs,
          use: [
            {
              loader: fileLoader,
              options: getFileLoaderOptions(appDir, isDev, false)
            },
            "image-webpack-loader"
          ],
          issuer: issuerForNonStyleFiles
        },
        {
          test: svgs,
          use: [
            {
              loader: fileLoader,
              options: getFileLoaderOptions(appDir, isDev, true)
            },
            "image-webpack-loader"
          ],
          issuer: issuerForStyleFiles
        },
        fileRulesNonStyle,
        fileRulesStyle
      ]
    }
  };

  return merge(config, override);
}

Can I have some help please ?

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

1 participant