Using Webpack dev server to automatically export CSS files when they are changed

Currently, I am integrating .SASS into a single .CSS file using webpack. When I execute "webpack" in the terminal, it successfully exports the file. However, when I use "webpack-dev-server", it detects the changes but does not generate or update the output .CSS file:

var webpack = require('webpack');
var path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');

module.exports = {
    devtool: 'inline-source-map',
    entry: [
        'webpack-dev-server/client?http://127.0.0.1:8080/',
        'webpack/hot/only-dev-server',
        './src'
    ],
    output: {
        path: path.join(__dirname, 'public'),
        filename: 'bundle.js',  // final .js file export
        publicPath: '/public'
    },
    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                loaders: ['react-hot', 'babel?presets[]=react,presets[]=es2015']
            },

           {
                test: /\.scss$/, loader: ExtractTextPlugin.extract('css!sass') // SASS loading configuration
            }

        ]
    },

    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NoErrorsPlugin(),
        new ExtractTextPlugin("./bundle.css") // CSS file export configuration
    ],

    resolve: {
        modulesDirectories: ['node_modules', 'src'],
        extensions: ['', '.js', '.scss'],
        root: [path.join(__dirname, './src')]
    }
};

Although it functions as expected with just "webpack," I am curious about how to trigger the file generation process using the server. This way, I can avoid manually entering commands in the terminal each time I need to update the styles.

Answer №1

It's perfectly okay. webpack-dev-server does not save any files to the disk. It only serves them from memory. That's why you see this message in the terminal:

Your project is live at http://localhost:9000/
Webpack output is being served from /
Content not managed by webpack is being served from /Users/dd/Desktop/apps/webpack-starter/dist

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

Is there a way to incorporate a JavaScript variable as the value for CSS width?

I created a scholarship donation progress bar that dynamically adjusts its width based on the amount donated. While I used CSS to handle the basic functionality, I am now trying to implement JavaScript for more advanced features. My goal is to calculate ...

I'm having trouble getting my customized CSS to work properly in a WordPress theme that's using Bootstrap

Currently diving into the world of Wordpress development and creating my own theme. Utilizing bootstrap along with some custom CSS, but having trouble getting everything to work together in harmony. Below is a snippet of my functions code: <?php func ...

Change the color of the div's background

My grid created using bootstrap 3 divs consists of a button, followed by a radio button, and then another button. I want to highlight these elements with a consistent background color that stretches across like a single row. Check out my attempt on this f ...

Is it possible for me to create a hyperlink that directs to a javascript function?

Here is the code I am currently using: <input class="button" type="button" value="Mark" onClick="doCheck('mark');" \> However, I would like to replace the button with a hyperlink using the <a> tag. Is it possible to achieve ...

What steps do I take to align my menu in the center of the page?

I am looking to create a CSS horizontal menu that is centered within the header element and stays in the middle even when the browser window is resized. I have attempted using margin: auto;, but it has not produced the desired result. Check out the jsfi ...

Omit a specific div element when applying a background overlay

Looking to create a block with an overlay hover effect - defaulting to a weak black background color and changing to no black background on hover. I want to include an icon and text in the center that remain unaffected by the hover state. How can I preven ...

"Enhance your audio experience across all browsers with the revolutionary

I am looking for a way to play an mp3 file endlessly when the user opens my website. I need a lightweight crossbrowser solution that works in all browsers, including IE. Any suggestions? ...

Placing a div on top of an image with a responsive height that adjusts to the image size using Bootstrap 4.3

I have created two layers on top of an image: one is a filter that darkens the image, and the other contains random text. I want to align them to the image with the same width and height but I'm not sure how to achieve that. I attempted to use backgro ...

IE7 causing mispositioning of `<ul>` in jQueryUI Autocomplete results

I have successfully implemented the jQueryUI Autocomplete function and here is how I have customized it: appendTo: "#results", open: function(){ var position = $("#results").position(), left = position.left, top = position.top ...

Images are not being shown on the desktop carousel display

I am encountering an issue with my carousel. When I attempt to decrease the height of the carousel, the entire image is not being displayed properly (on desktop), although it works fine on mobile devices. My goal is for the carousel not to take up the ent ...

Differences in heights of the Bootstrap carousel in a responsive mobile view

My website features numerous carousel sliders that function perfectly on PC, but appear unappealing on mobile devices. The issue at hand is as follows: Imagine each carousel slide contains a maximum of 4 images, all within a col-md-3.col-12 div. <div ...

Having trouble with the background-image not displaying and the image not showing up as expected?

I am experiencing an issue with my background image not displaying on my website. I am utilizing HTML5 along with CSS. Below is the code snippet in question: body { width: 1000px; background-image: url(background.jpg); background- ...

Place a stationary element under another stationary element

I have a dilemma with two fixed elements on my website. One of them can toggle between display: block and display: none, while the other is always visible. I want both elements to stay at the top of the webpage without overlapping each other. I've co ...

Guidelines for managing a catch function

I have recently set up a database in Cloud Firestore and am looking to populate it with information using input fields. However, I've encountered an issue where if the input fields are left empty, the information still gets stored and the catch functi ...

Is there a way to modify the color of ASCII art letters within HTML's <pre> tags?

For this illustration, I aim to transform the letter "y" into a shade of blue. ,ggggggggggggggg dP""""""88""""""" Yb,_ 88 `"" 88 88 88 gg gg 88 I8 8I gg, 88 ...

Is there a way to make two divs stack on top of each other without using media queries, while ensuring that text

I have successfully created a responsive video for my website and wrapped text around the video, but now I'm struggling to make them work together seamlessly. My ideal scenario is: For the desktop version: To look like this: Mobile version The bes ...

Personalized radio buttons for displaying or concealing content

My goal is to create an interactive email content block that can display or hide content based on user selection. It was functioning properly until I decided to customize the label. After wrapping the input and label in a div, the functionality ceased. I s ...

Tips for aligning text centrally beneath an iFrame without it getting pushed off course by the wrapped text

My iframe is floating left with text wrapped around it. I have been trying to center align the text below it, but all my attempts seem to mess up the entire format. I have included the code and preview link here: https://codepen.io/Religion/pen/QWydbow. ...

What is the best way to incorporate code into a page with numerous conflicting CSS styles, without resorting to Scoped CSS?

Struggling to incorporate tab code into a page with conflicting CSS? Even after attempts to edit classes and labels, the original code fights back against the new additions. While scoped CSS seems like the perfect fix, it's not widely supported yet. ...

What is the best way to ensure my input fields remain on a single line while also centering the containing DIV?

I assigned the CSS class "searchField" to a few input fields .searchField { display: inline-block; } Below is the HTML code for these input fields... <div id="searchForm"> Search For Results<br> <form id="search-form" action="/races/ ...