最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - webpack-dev-server not creating dist folder on local - Stack Overflow

programmeradmin0浏览0评论

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",
    ...
  }
}

发布评论

评论列表(0)

  1. 暂无评论