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

Resize from SCSS doesn't work #147

Open
albertpeiro opened this issue Apr 17, 2020 · 3 comments
Open

Resize from SCSS doesn't work #147

albertpeiro opened this issue Apr 17, 2020 · 3 comments

Comments

@albertpeiro
Copy link

albertpeiro commented Apr 17, 2020

I couldn't find anywhere a mention to this not working so I assumed this should work but please correct me if I'm wrong. Also THANK YOU for this library - it's awesome.

Resizing via url params works when I use it with require.
It doesn't seem to work from scss files though.

Image size remains 2048 when opening it

Screenshot 2020-04-17 at 19 40 44

&.cover-sailing {
    background-size: cover;
    background-position: center;
    background-image: url("../images/photos/albert-alghero-1.jpg?resize&size=500");
  }

const nextConfig = {
  webpack: (config) => {
    config.resolve.alias["~"] = path.resolve(__dirname);
    return config;
  }
};

module.exports = withPlugins(
  [
    [
      optimizedImages,
      {
        /* config for next-optimized-images */
        optimizeImagesInDev: true
      }
    ]

    // your other plugins here
  ],
  nextConfig
);

I'm on:

  • Mac catalina 10.15.4
  • Node v12.13.1
  • NPM 6.12.1
"dependencies": {
    "axios": "^0.19.2",
    "bootstrap": "^4.4.1",
    "date-fns": "^2.12.0",
    "greeting": "^1.0.6",
    "imagemin-gifsicle": "^7.0.0",
    "imagemin-mozjpeg": "^8.0.0",
    "imagemin-optipng": "^7.1.0",
    "imagemin-svgo": "^7.1.0",
    "isomorphic-unfetch": "^3.0.0",
    "lqip-loader": "^2.2.0",
    "next": "^9.3.2",
    "next-compose-plugins": "^2.2.0",
    "next-optimized-images": "^2.5.8",
    "react": "^16.13.1",
    "react-bootstrap": "^1.0.0",
    "react-bootstrap-icons": "^1.0.1-alpha3",
    "react-dom": "^16.13.1",
    "react-map-gl": "^5.2.3",
    "reactstrap": "^8.4.1",
    "responsive-loader": "^1.2.0",
    "sass": "^1.26.3",
    "sharp": "^0.25.2",
    "swr": "^0.1.18"
  },
  "devDependencies": {
    "@types/node": "^13.9.8",
    "@types/react": "^16.9.31",
    "typescript": "^3.8.3"
  }
@benedfit
Copy link

Same goes for ?webp. I'm unable to utilise the functionality via Sass files

@keadex
Copy link

keadex commented Nov 2, 2020

Same for me for ?webp. Any update?

@nad182
Copy link

nad182 commented Feb 20, 2021

I also can neither resize background-image in filename.module.scss, nor convert it to webp. Any of

background-image: url('../public/images/hero-bg.png?webp');
background-image: url('../public/images/hero-bg.png?resize&size=500');

results in the full jpeg image (i.e. localhost:3000/_next/static/images/hero-bg-3ffba3cef92d0972f13f317d74e1bcab.png).
This closed issue mentions that at least converting to webp should be possible.
This is my next.config.js:

const withPlugins = require('next-compose-plugins');
const optimizedImages = require('next-optimized-images');
const responsiveLoaderSharp = require('responsive-loader/sharp');

module.exports = withPlugins([
  [optimizedImages, {
    responsive: {
      adapter: responsiveLoaderSharp,
      sizes: [300, 320, 640, 960, 1200, 1800, 2400],
      placeholder: true,
      placeholderSize: 40,
    },
    optimizeImagesInDev: true,
  }],
]);

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

4 participants