“webpack compilar o arquivo sass to css” Respostas de código

webpack compilar o arquivo sass to 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 compilar SCSS para o arquivo CSS

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

NPM compilar SASS para 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

Respostas semelhantes a “webpack compilar o arquivo sass to css”

Perguntas semelhantes a “webpack compilar o arquivo sass to css”

Procure respostas de código populares por idioma

Procurar outros idiomas de código