Giter VIP home page Giter VIP logo

Comments (4)

Tragio avatar Tragio commented on June 21, 2024 2

@unematiii it's now working 😄 really thank you for all the help!!!

from css-loader-short-classnames.

unematiii avatar unematiii commented on June 21, 2024

I did some research and apparently Gridsome CLI generated projects seem to pull in css-loader version 2.1.1 (latest is 4.3.0), and for this version options should be provided differently:

gridsome.config.js:

const { getLocalIdentName } = require("css-loader-shorter-classnames");

const isProduction = process.env.NODE_ENV === "production";

module.exports = {
  // ... other config options
  css: {
    loaderOptions: {
      css: {
        localIdentName: "[local]-[hash:base64:8]",
        ...(isProduction ? { getLocalIdent: getLocalIdentName() } : {}),
      },
    },
  },
};

Attaching sample project with working configuration.

from css-loader-short-classnames.

Tragio avatar Tragio commented on June 21, 2024

Hello @unematiii!! You're amazing, really thank you for your quick reply.

I took your sample project, I added the Buefy and imported into the main.js. If you try to do gridsome build you notice that the output is the same. There's no effect happening. 🤔

Here is the updated sample project.

Really thank you for the help!

from css-loader-short-classnames.

unematiii avatar unematiii commented on June 21, 2024

Hey!

Actually everything in Vue SFC-s do get correct class names. I guess <style module></style> in *.vue components does the trick here. (Observe the first lines of the sample projects built css file). You can enable modules for all the the other css assets by setting additionally modules: true:

module.exports = {
  // ... other config options
  css: {
    loaderOptions: {
      css: {
        modules: true,
        localIdentName: "[local]-[hash:base64:8]",
        ...(isProduction ? { getLocalIdent: getLocalIdentName() } : {}),
      },
    },
  },
};

But beware, enabling modules for external libraries can cause some problems: if you yourself or the JS implementation of the library rely on static class names. Then you should use different configuration for the styles in you app and for those of external libraries.

from css-loader-short-classnames.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.