出口Output

影响编译的输出
告诉webpack怎样编译输出的文件
允许多个入口一个出口的情况。

用法

const config = {
  output: 'bundle.js'
};

module.exports = config;

选项

以下是你可以设置的值的output的选项。

output.chunkFilename

output.crossOriginLoading

该选项实现跨域加载模块
可以的值是:false anonymous use-credentials

output.devtoolLineToLine

output.filename

命名每个出口文件。
不必明确绝对路径。
使用output.path设置项,设置具体位置。
filename仅仅命名文件名字即可。

{
  entry: './src/app.js',
  output: {
    filename: 'bundle.js',
    path: __dirname + '/build'
  }
}

// writes to disk: ./build/bundle.js

多个入口
如果你是用多个块。
可以使用分发来确保每个文件的名字不重复

{
  entry: {
    app: './src/app.js',
    search: './src/search.js'
  },
  output: {
    filename: '[name].js',
    path: __dirname + '/build'
  }
}

// writes to disk: ./build/app.js, ./build/search.js

output.hotUpdateChunkFilename

output.hotUpdateFunction

output.hotUpdateMainFilename

output.jsonpFunction

output.library

output.libraryTarget

output.path

output.sourceMapFilename


farmerz
1.4k 声望93 粉丝

可可西里,可可西里,我只是想去看一看。