Answer the question
In order to leave comments, you need to log in
Why doesn't webpack compile sass to css and put it in dist?
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ImageminPlugin = require("imagemin-webpack");
module.exports = {
devtool: "source-map",
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js",
publicPath: "/"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
},
},
{
test: /\.(sass|scss)$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
sourceMap: true,
minimize: true,
url: false
}
},
// 'postcss-loader',
{
loader: "sass-loader",
options: {
sourceMap: true
}
}
],
},
]
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
}),
new HtmlWebpackPlugin({
template: "./src/index.html"
}),
],
resolve: {
extensions: ['.js', '.scss', '.sass']
},
devServer: {
overlay: true
},
};
Answer the question
In order to leave comments, you need to log in
Option 1: do import sass from js
Option 2: write sass file as 1 more entry in webpack:import './main.sass';
module.exports = {
devtool: "source-map",
entry: ["./src/main.sass", "./src/index.js"],
// ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question