ahui
ahui
静态资源上传到cdn有更加简便而且合理的做法,就是配置webpack的`output.publicPath`为你线上的cdn地址,这样打包完以后,html中script标签的src地址就不会再是相对地址,而是前缀为cdn地址的全路径,这个时候再把打包生成的静态资源整个上传到cdn,然后再单独发布html到服务器就好了,这样还不用单独再处理例如css文件的中的图片url这类的问题.对应vue的wedpack template,可以看看[config/index.js](https://github.com/vuejs-templates/webpack/blob/develop/template/config/index.js#L57-L58),[build/utils.js](https://github.com/vuejs-templates/webpack/blob/develop/template/build/utils.js#L7-L12)和[build/webpack.base.conf.js](https://github.com/vuejs-templates/webpack/blob/develop/template/build/webpack.base.conf.js#L19-L21)这几个地方
@berwin 文件名不会有影响,因为文件名的生成也是在webpack内部生成的,至于cdn地址随机的话,如果cdn地址只有上传的那一刻才能确定的话那估计就没法了
@berwin 抱歉啊,居然到现在才看到at我的信息,我只是个前端切图仔不是大佬哈😅 > 如果cdn地址只有上传的那一刻才能确定的话那估计就没法了 同理如果上传到cdn时文件名会发生变化的话,也是没有办法简单通过配置实现的 所以之前的评论并不知道你的场景是如此 了解到实际场景之后,我觉得像你之前实现也并没有什么问题 后面我自己思考了一下,也没有想到更好方法 思考得出的可能解也只是把上传获取最终文件名的步骤放到plugin中去实现而已 不知道从那时到现在有没有更进一步优化呢?
@gustojs ,same problem with you. but i find that import inside the App.vue juse do the trick. checkout [here](https://github.com/funkyLover/vue-webpack-meteor-todo/blob/master/src/App.vue#L24)
这里还有个新的问题,如果去掉 `normalize.css` 依然会报错 ```bash 2020-03-11 17:56:53,392 ERROR 55180 [admin/home.js] server render bundle error, try client render, the server render error ReferenceError: document is not defined at eval (webpack:///./node_modules/vue-echarts/dist/vue-echarts.js?:1:11870) at eval...
@hubcarl 感谢,那第一个问题方便帮忙看下吗 ```js import 'normalize.css'; ```
@cc2005726 ``` javascript var indexOf = function(array, index) { return array[index]; } juicer.register('indexOf', indexOf); ``` 模板里这样调用 `${data, index | indexOf}`
@cc2005726 恩,这个我在实际用的时候也遇到了