Open jackieli123723 opened 6 years ago
const HtmlWebPackPlugin = require("html-webpack-plugin"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); module.exports = { module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: { loader: "babel-loader" } }, { test: /\.html$/, use: [ { loader: "html-loader", options: { minimize: true } } ] }, { test: /\.css$/, use: [MiniCssExtractPlugin.loader, "css-loader"] } ] }, plugins: [ new HtmlWebPackPlugin({ template: "./src/index.html", filename: "./index.html" }), new MiniCssExtractPlugin({ filename: "[name].css", chunkFilename: "[id].css" }) ] };
## webpack4 use: [MiniCssExtractPlugin.loader, "css-loader"] { test: /\.scss$/, exclude: /(node_modules|bower_components)/, use: [ { loader: 'style-loader', // 将 JS 字符串生成为 style 节点 }, { loader: 'css-loader', // 将 CSS 转化成 CommonJS 模块 }, { loader: 'sass-loader', // 将 Sass 编译成 CSS }, ], }, { //test: que tipo de archivo quiero reconocer //use : que loader se va encargar del archivo test:/\.scss$/, //use: ['style-loader','css-loader'], use: [ MiniCssExtractPlugin.loader, "css-loader","sass-loader" //ExtractTextPlugin.extract({ // fallback:'style-loader', // use:'css-loader' ] }, { test: /\.scss$/, use: [ MiniCssExtractPlugin.loader, // "style-loader", 'css-loader', { loader: 'postcss-loader', options: { plugins: () => [require('autoprefixer')] } }, 'sass-loader' ] } [MiniCssExtractPlugin.loader, "style-loader","css-loader","sass-loader"]
webpack 配置改变