This repository has been archived by the owner on Dec 12, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 288
cooking 如何引入happypack #125
Labels
Comments
happypack 似乎无视 vue-loader。我的做法是尽可能第三方库都用 cdn;用 buble 替代 babel 这是我最近在写的一个项目的配置,供参考 var resolve = require('path').resolve;
var cooking = require('cooking');
cooking.set({
entry: './src/entry.js',
dist: './dist',
template: './index.tpl',
devServer: {
port: 8099,
host: '0.0.0.0',
proxy: {
'/api': {
target: 'http://localhost:7790',
changeOrigin: true,
pathRewrite: { '^/api': '' }
}
}
},
clean: true,
hash: true,
sourceMap: true,
minimize: true,
chunk: true,
publicPath: '/',
extractCSS: true,
alias: {
src: resolve(__dirname, 'src')
},
externals: process.env.NODE_ENV === 'production' ? {
vue: 'Vue',
vuex: 'Vuex',
'vue-router': 'VueRouter',
'element-ui': 'ELEMENT'
} : {},
extends: ['vue2', 'buble', 'lint', 'saladcss']
});
module.exports = cooking.resolve(); index.tpl (cdn 地址已隐去) <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>xxx</title>
</head>
<body>
<div id="app"></div><% if (process.env.NODE_ENV === 'production') { %>
<script src="//cdn.com/inexorabletash/polyfill/v0.1.27/polyfill.min.js"></script>
<script src="//cdn.com/vuejs/vue/v__version__/dist/vue.runtime.min.js"></script>
<script src="//npm.cdn/element-ui@__version__/lib/index.js"></script>
<script src="//cdn.com/vuejs/vuex/v__version__/dist/vuex.min.js"></script>
<script src="//cdn.com/vuejs/vue-router/v__version__/dist/vue-router.min.js"></script><% } %>
</body>
</html> 然后自己写了个脚本替换 这个项目 build 用时也就 20 来秒,启动只用 10 秒 |
我们是内部系统 不能用cdn比较特殊 |
那可以用 dllPlugin 把第三方库单独打包,build 花的时间基本上都是其他库的压缩和合并 |
好的 谢谢 QingWei大神 万分感谢 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
目前构建时间 要2分钟 想引入happypack 或者有没有优化的方案?
The text was updated successfully, but these errors were encountered: