Output配置output配置选项告诉webpack如何将编译后的文件写入磁盘。请注意,虽然可以有多个entry点,但只output指定了一个配置。

  • filename to use for the output file(s).

webpack.config.js

module.exports = {
output: {
filename: 'bundle.js',
}
};

This configuration would output a single bundle.js file into the dist directory.

如果您的配置创建了多个“块”(与多个入口点一样或使用CommonsChunkPlugin等插件时),则应使用替换来确保每个文件都具有唯一名称。

module.exports = {
entry: {
app: './src/app.js',
search: './src/search.js'
},
output: {
filename: '[name].js',
path: __dirname + '/dist'
}
}; // writes to disk: ./dist/app.js, ./dist/search.js

高级

以下是使用CDN和资产哈希的更复杂的示例:

config.js

module.exports = {
//...
output: {
path: '/home/proj/cdn/assets/[hash]',
publicPath: 'http://cdn.example.com/assets/[hash]/'
}
};

如果publicPath在编译时不知道输出文件的最终结果,则可以将其留空并在运行时通过__webpack_public_path__入口点文件中的变量动态设置:

__webpack_public_path__ = myRuntimePublicPath;

// rest of your application entry

最新文章

  1. HSV与RGB颜色空间的转换
  2. 【转】CentOS5.6下配置rsync内网同步数据到外网
  3. Ubuntu每次启动都显示System program problem detected的解决办法
  4. HTTP及网络安全
  5. mysqldump导出--数据+结构+(函数+存储过程)
  6. Winform的窗体美化心酸路
  7. Sql面试常考题(持续添加)
  8. BZOJ_1003_[ZJOI2006]_物流运输_(动态规划+最短路)
  9. 新建应用母版页的网页index.aspx,about.aspx,login.aspx
  10. oracle 11g 11.2.0.1 设置HuagePage导致TRC 变大 变多
  11. python 在mongo 中建立索引
  12. Ubuntu 14.04 安装 Sublime Text 3
  13. 负载均衡手段之DNS轮询
  14. win10常用快捷键
  15. MVC 验证规则扩展(当RoleID 属性值为A,B 时,Email 属性必填)
  16. day89
  17. hdu4812 逆元+树分治
  18. [转载]谈谈document.ready和window.onload的区别
  19. .mht文件转换为html
  20. thinkphp3.2开启静态缓存与缓存规则设置

热门文章

  1. (转)VS2010结合水晶报表做条码标签打印功能
  2. 《HTML5 与 CSS3 基础教程(第 8 版)》
  3. 阶段1 语言基础+高级_1-3-Java语言高级_04-集合_01 Collection集合_3_Collection集合常用功能
  4. IDE(Pycharm&&IDEA)配置文件模版
  5. 编译的时候出现"/usr/bin/ld: cannot find -lz
  6. 远程访问其他主机的Mysql(Ubuntu)
  7. Struts2的核心配置文件
  8. linux shell中的正则表达式
  9. The Log-Structured Merge-Tree(译)
  10. [19/05/08-星期三] JDBC(Java DataBase Connectivity)_ORM(Object Relationship Mapping, 对象关系映射)