“webpack compile sass au fichier CSS” Réponses codées

webpack compile sass au fichier CSS

const path = require('path');

const FixStyleOnlyEntriesPlugin = require("webpack-fix-style-only-entries");

module.exports = {
  entry: [
    __dirname + '/src/js/app.js',
    __dirname + '/src/scss/app.scss'
  ],
  output: {
    path: path.resolve(__dirname, 'dist'), 
    filename: 'js/app.min.js',
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: [],
      }, {
        test: /\.scss$/,
        exclude: /node_modules/,

        type: 'asset/resource',
        generator: {
          filename: 'css/[name].min.css'
        },

        use: [
          'sass-loader'
        ]
      }
    ]
  },
  plugins: [
    new FixStyleOnlyEntriesPlugin({ extensions:['scss'] }),
  ],
};
Vitalik-Hakim

WebPack 5 Compiler SCSS dans le fichier CSS

module.exports = {
    module: {
        rules: [{
            test: /\.scss$/,
            use: [{
                loader: "sass-loader",
                options: {
                    minimize: true
                }
            }]
        }]
    }
};
SECRET MYSTERY

NPM compile les sass à CSS

 #compiles a single file manually.
 node-sass my-styles.scss my-styles.css 
 #compiles all the files in a folder manually.
 node-sass my-sass-folder/ -o my-css-folder/
 # compiles all the files in a folder automatically 
 #whenever the source file(s) are modified. -w adds 
 #a watch for changes to the file(s).
 node-sass -w sass/ -o css/
Encouraging NeoBliz

Réponses similaires à “webpack compile sass au fichier CSS”

Questions similaires à “webpack compile sass au fichier CSS”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code