admin管理员组

文章数量:1356257

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'])
    ]
};

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'])
    ]
};
Share Improve this question asked Aug 4, 2017 at 6:03 m-ketanm-ketan 1,3082 gold badges18 silver badges24 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

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

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

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

本文标签: javascriptwebpackdevserver not creating dist folder on localStack Overflow