对webpack的初步研究3
2024-09-05 20:57:30
Output配置output
配置选项告诉webpack如何将编译后的文件写入磁盘。请注意,虽然可以有多个entry
点,但只output
指定了一个配置。
- A
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
最新文章
- HSV与RGB颜色空间的转换
- 【转】CentOS5.6下配置rsync内网同步数据到外网
- Ubuntu每次启动都显示System program problem detected的解决办法
- HTTP及网络安全
- mysqldump导出--数据+结构+(函数+存储过程)
- Winform的窗体美化心酸路
- Sql面试常考题(持续添加)
- BZOJ_1003_[ZJOI2006]_物流运输_(动态规划+最短路)
- 新建应用母版页的网页index.aspx,about.aspx,login.aspx
- oracle 11g 11.2.0.1 设置HuagePage导致TRC 变大 变多
- python 在mongo 中建立索引
- Ubuntu 14.04 安装 Sublime Text 3
- 负载均衡手段之DNS轮询
- win10常用快捷键
- MVC 验证规则扩展(当RoleID 属性值为A,B 时,Email 属性必填)
- day89
- hdu4812 逆元+树分治
- [转载]谈谈document.ready和window.onload的区别
- .mht文件转换为html
- thinkphp3.2开启静态缓存与缓存规则设置
热门文章
- (转)VS2010结合水晶报表做条码标签打印功能
- 《HTML5 与 CSS3 基础教程(第 8 版)》
- 阶段1 语言基础+高级_1-3-Java语言高级_04-集合_01 Collection集合_3_Collection集合常用功能
- IDE(Pycharm&;&;IDEA)配置文件模版
- 编译的时候出现";/usr/bin/ld: cannot find -lz
- 远程访问其他主机的Mysql(Ubuntu)
- Struts2的核心配置文件
- linux shell中的正则表达式
- The Log-Structured Merge-Tree(译)
- [19/05/08-星期三] JDBC(Java DataBase Connectivity)_ORM(Object Relationship Mapping, 对象关系映射)