代码之家  ›  专栏  ›  技术社区  ›  Thunfische

如何选择Webpack中的输出文件目录?

  •  0
  • Thunfische  · 技术社区  · 7 年前

    当我使用“webpack--modedevelopment”运行webpack时,它会创建一个dist文件夹,并将bundle.js放入其中。我想让它创建并放在同一个目录中。我该怎么做?

        module.exports = {
    
            entry: "./main.js", //relative to root of the application
            output: {
                filename: "./app.bundle.js" //relative to root of the application
            },
            watchOptions: {
                aggregateTimeout: 300,
                poll: 1000
            }
        }
    
    1 回复  |  直到 7 年前
        1
  •  3
  •   JohMun    7 年前

    您可以使用 path 财产。

    output: {
      path: __dirname + '/dist',
      filename: 'bundle.js'
    }
    

    将其更改为: path: __dirname,