m-ketan
m-ketan

Reputation: 1308

webpack-dev-server not creating dist folder on local

The webpack-dev-server is bundling the html, scss and js files successfully and the output is also getting served on localhost:8080 but the dist folder is not getting created on local. Following is my webpack configuration:

var extractPlugin = new ExtractTextPlugin({
   filename: 'main.css'
});

module.exports = {
    entry: './src/index.js',
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js',
    },
    devtool: 'inline-source-map',
    devServer: {
      port: 3000
    },
    plugins: [
        extractPlugin,
        new HtmlWebpackPlugin({
            template: 'public/index.html'
        }),
        new CleanWebpackPlugin(['dist'])
    ]
};

Upvotes: 6

Views: 4272

Answers (2)

Emanuel Saramago
Emanuel Saramago

Reputation: 506

Adding --watch to npm script solved the problem for me.

{
  ...
  "scripts": {
    "dev": "webpack --mode development --watch",
    ...
  }
}

Upvotes: 0

Chris Baldwin
Chris Baldwin

Reputation: 589

The webpack-dev-server serves the created bundle from memory and does not write it to the dist directory.

Upvotes: 8

Related Questions