-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.roadhogrc hash设置为true build后的html的js和css没有带上hash #386
Comments
正想提这个issue,看到你提了。刚从dva默认的0.5.4升到1.1.1,试了一下hash,build出来的确实是带hash了,但index.html里的还是/index.js和/index.css,所以每次build完还得去dist里改一下index.html。。。略微有点蛋疼。。。 |
https://github.com/zuiidea/antd-admin/blob/master/webpack.config.js 参考这里,用了HtmlWebpackPlugin |
+1 单页的项目也遇到这个问题 |
#391 解决方案 @smilefufu |
仔细看 Release Note,需要有 |
感谢,自己尝试了一下,已经搞定。
HTMLWebpackPlugin会自动往里面插入带hash的css和js。此模式下原publish下的index.html就没用了,而是用index.ejs作为模板。 |
@smilefufu 还有其他配置吗? src 下添加这个文件 配置里打开 hash: true, npm run build 还是老样子 |
@huyawei 没有别的配置了,你检查一下是不是roadhog版本不对?老版本roadhog不支持hash这个参数。我roadhog版本号是1.1.1 |
@smilefufu您好 我按照你们讨论的写法如下写了,但是打包出来的文件名还是没有处理过的。配置如下: 已经在src下创建index.ejs的文件 package.json: |
@huangxiaohao roadhog 2.0 的配置文件改成.webpackrc,你写.roadhogrc肯定无效嘛。 |
@smilefufu 您好 感谢您的回复。 {
"entry": "src/index.js",
"extraBabelPlugins": [
["import", { "libraryName": "antd", "style": "css" }]
],
"proxy": {
"/api": {
"target": "http://192.168...",
"changeOrigin": true,
"pathRewrite": { "^/api": "" }
}
},
"env": {
"development": {
"extraBabelPlugins": [
"dva-hmr",
"transform-runtime",
["import", { "libraryName": "antd", "style": "css" }]
]
},
"production": {
"extraBabelPlugins": [
"transform-runtime",
["import", { "libraryName": "antd", "style": "css" }]
]
}
},
hash : true,
} 但是结果还是一样,打包出来的文件名还是没有加hash |
@huangxiaohao
|
非常感谢你的分享,帮助我解决了问题。 =3= |
@smilefufu 感谢回复 这一句我也加上了但是还是没有效果。😢 |
Environment(required) | 环境(必填)
What did you do? Please provide steps to re-produce your problem.(请提供复现步骤)
.roadhogrc.js
pubulic文件夹下的index.html
package.json
项目结构
执行 npm run build 后的项目结构
What do you expected?(预期的正常效果)
dist目录下的index.html内容为
What happen?(发生了何种非正常现象)
可是实际结果,dist目录下的index.html内容为
js和css并么有带上hash
The text was updated successfully, but these errors were encountered: