You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
报出了错误
查资料,说要配置webpack的配置项
resolve.alias,说是组件别名,让js里引用路径可以简写
这样让vue对象挂上compile方法。
output.filename:'[name].js?[hash]'
将会使在file://协议访问时,访问不到文件,所以作electron开发时,不要带上[hash]
externals 配置项是为了使用全局变量代替对库的引用,库内容不用再打包到app.js中,适合于库已经在页面中引入的情况,
本项目最后没有使用这个方法,而用上了 DllPlugin、DllReferencePlugin 插件 http://blog.csdn.net/ailongyang/article/details/59494570 ,配合js中写 window.axios = axios 将变量暴露到全局。
在webpack2中改为了
babel的插件由babel-preset-es2015更换为babel-preset-env (http://2ality.com/2017/02/babel-preset-env.html)
上面的配置让babel将js编译目标定为chrome54(尚不支持async/await),会将async编译成yield实现。
支持的浏览器写法见 https://github.com/ai/browserslist
但在实际使用中没有使用此方案,
最开始用的js引入到页面上,库都自己暴露到了全局(但有些库(如axios)可能写法与electron环境(存在require方法)冲突,不能导出到全局),后来使用 DllPlugin 插件与 ProvidePlugin 插件冲突,无法暴露库到全局。
感觉 BabiliPlugin 压缩js的速度很慢。1M大小的js要10秒时间甚至更久。
webpack-dev-server 没有提reload浏览器的接口(也许有,但找了一阵资料没找到),又不能监听没有被js导入的css文件的修改,所以我使用了browser-sync来启动服务和监听资源文件的修改、刷新浏览器中的页面。 而后在开发electron时换成了electron-connect来刷新electron中的页面。
最开始用 gulp-watch 监听vue文件的修改,然后调用webpack-stream编译js,再通过browser-sync通知浏览器中页面刷新。
后来为了使用上webpack的watch方法来加快开发时的编译速度,流程改为,webpack.watch监听主要的js文件的修改,然后(electron-connect或browser-sync)通知页面刷新。build时比较慢,但开发时热编译性能有所提升。
以后可能要用到的一个插件 ContextReplacementPlugin
webpack/webpack#3128 (comment)
The text was updated successfully, but these errors were encountered: