Utilizing webpack to extract CSS from SCSS files

I've been working on integrating webpack into my asp.net mvc core project. While I've successfully bundled js files, I'm facing an issue with extracting css from scss files.

var path = require('path');
var extractTextPlugin = require("extract-text-webpack-plugin");
var cleanWebpackPlugin = require('clean-webpack-plugin');

module.exports = {
    entry: {
        'role/role': './scripts/role/roleVM.ts',
        main: './scripts/main.ts',
        vendor: ["jquery"],
    },
    output: {
        filename: '[name].js',
        path: path.resolve(__dirname, 'wwwroot/dist/js/')
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                loader: 'ts-loader',
                exclude: /node_modules/,
            },
            {
                test: /\.scss$/,
                use: extractTextPlugin.extract({
                    use: [{
                        loader: "css-loader", options: {
                            sourceMap: true
                        }
                    }, {
                        loader: "sass-loader", options: {
                            sourceMap: true
                        }
                    }],
                    fallback: 'style-loader'
                }),
                exclude: /node_modules/,
            },
        ]
    },
    plugins: [
        new cleanWebpackPlugin(['dist'], {
            root: path.resolve(__dirname, 'wwwroot'),
            verbose: true,
            dry: false
        }),
        new extractTextPlugin("./css/main.css")
    ],
    resolve: {
        extensions: [".tsx", ".ts", ".js", '.scss']
    }
};

Despite following the configuration above, when I build my project, the css files are not being created.

This is the command I am using:

npm run build --color=always
> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4d3d3f2227282e390d">[email protected]</a> build C:\project\src\test
> webpack
clean-webpack-plugin: C:\project\src\project\wwwroot\dist has been removed.
ts-loader: Using <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="691d10190c1b0c1919295b47">[email protected]</a> and C:\project\src\project\tsconfig.json
Hash: 2cdaff8d8177eedec094
Version: webpack 3.5.3
Time: 2203ms
       Asset     Size  Chunks                    Chunk Names
role/role.js   293 kB       0  [emitted]  [big]  role/role
   vendor.js   271 kB       1  [emitted]  [big]  vendor
     main.js  2.48 kB       2  [emitted]         main
   [0] ./scripts/role/roleVM.ts 400 bytes {0} [built]
 ...

It seems like the extract text plugin is being skipped. Is there anything missing in my configuration file?

Here is the current structure of my project:

└── Project
    ├── wwwroot
    │   └── scss
    │     └── main.scss
    └── scripts
    │   └── main.ts
    │
    └── webpack.config.js

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the significance of property placement in a Mongo query: at the beginning versus at the

Currently, I am in the process of creating a query to retrieve data from the mango collection. Interestingly, I have written the same query in two different ways. Here is my working query: db.getCollection('routes').find({"routes.routeId": "r1q ...

The Node.js application encounters a crash when attempting to create an index on an AWS EC2 instance, yet functions correctly on my personal computer

This is the schema definition for a location: const mongoose = require('mongoose'); const Schema = mongoose.Schema; let locationSchema = new Schema({ 'locationTitle': String, 'googlePlaceId': { 'type': Stri ...

How can I ensure that the appropriate 'this' is accessed within a callback function for an AJAX request?

When working with a callback function, I am having trouble accessing this. Instead, it seems to be pointing to the AJAX object rather than the object that initially invoked the onClickEmail function. I attempted to store a reference in a variable called th ...

Looking to update a form when clicking on the change button?

Two JSON files, "a.json" and "b.json", are in question. A different form needs to be displayed when the user clicks on each respective button. The issue arises when clicking on the second button does not show the second form as intended. The goal is to onl ...

Utilizing Promises in the apply function

I am currently working on a project in Node.js that utilizes bluebird for promise handling, as well as ES6 native promises. In both projects, I have a chain where I make a database query structured like this: some_function(/*...*/) .then(function () ...

Is there a way to determine if the objectids are alike?

Here is a function I wrote to verify if the username stored in the session matches the original commenter: async sameUser(id,uname){ const blogsCollection = await blogs(); id = ObjectId(id) let a; const finder = await blogsC ...

Using CSS and jQuery to Enhance Page Transitions

Seeking assistance with creating a unique page transition similar to this one: Basing the animation on my own design concept found here: Current experiment can be viewed at: https://jsfiddle.net/f7xpe0fo/1/ The animation does not align with my design vi ...

How to Retrieve JSON Response in Link Function within AngularJS Directive

I have decided to implement a chart library called Plotly in my project. To ensure reusability, I am creating a directive in AngularJS that will allow me to easily integrate the library in the future. The directive will receive an object as input to creat ...

I aim to add and modify the quantity of a specific item ID

When the item id already exists, the quantity should be added to the incoming quantity. If the id does not exist, then insert the id and its quantity. Here is an example of what should be inserted into the table: if item_id=array(24,25); quantity=arra ...

How to create vertical spacing between <a> elements within the same div using HTML and CSS

Currently, the layout in picture 1 shows how my content is displayed. I am looking to create spacing (bottom margin?) between the images like the example in picture 2. The two side-by-side blocks are separate DIVs, and the images within each line belong to ...

Can you explain the purpose of the "--prod" flag in the command "npm run build --prod"?

Currently enrolled in the fullstackopen course, I have reached a section that involves generating production build files for a React application and transferring them to the backend directory for static file hosting. There is a suggestion provided to strea ...

Tips for beginning with running vue js examples/demos

Is it possible to test my local server side REST endpoints by using the demo here? I'm not sure where to start - any guidance on how to edit and try out the demo? For example, I've cloned this repository from https://github.com/pespantelis/vue-t ...

JavaScript: Invoking a nested function within a namespace

script1.js var MyNamespace = {}; MyNamespace.addNewFunction = function(a,b,c) { function doSomething() { // Perform some action here } } script2.js MyNamespace.addNewFunction.doSomething() ?? I’m a bit unsure on how to access the content ...

Toggle between fading in and out by clicking the button using a div

I'm having trouble getting my fade menu div to work properly. I want it to fade in when the menu button is clicked and fade out when the menu button is clicked again. Despite following various tutorials and researching other questions, I can't se ...

Fetch replicated popup (bootstrap)

Is it possible to load a newly cloned modal with bootstrap? I am looking to dynamically load multiple modals, but currently facing an issue while attempting to load just one new modal. While there are solutions available for loading cloned elements withi ...

Why is the Vue Yandex Maps package failing to function in Vue 3 when utilizing the defineCustomElement feature?

I am currently working on 2 different projects in Vue 3 that involve utilizing vue yandex maps: First project: You can view a demo of the first project where Vue Yandex Maps is being used by clicking here. In this project, the package is registered as fo ...

What is the process for resizing a texture render target following a window resize event?

My intention was to improve the texture quality, but instead of achieving my goal, I encountered an issue where the same texture is being stretched over a larger area, resulting in unwanted staircase artifacts. I tried updating various elements like camera ...

Encountering unexpected fetch requests to JSON files when using getStaticProps/getStaticPaths

My webpage seems to be functioning correctly, however I have noticed that in the console there are 5, 404 errors appearing on fetch requests. It's puzzling where these errors are originating from. Interestingly, these 404 errors only occur in the pro ...

Tips on including variables within quotation marks in JavaScript

I'm currently working on a JavaScript project using Pug. My goal is to use Express and MongoDB to develop a CRUD application that generates an edit button for each post, triggering a specific event when clicked. However, instead of the desired resul ...

What is the reason behind having to restart the npm server each time?

When first learning Reactjs with VSCode, there was no need to restart the server after making modifications. However, now I find that I must restart the server every time I make a change in order for those changes to be applied. ...