webpack

webpack构建vue项目警告

月盾
bundle.js:935 [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. (found in <Root>) 解决方案:与entry属性平级添加 resolve: { alias: { 'vue$': 'vue/dist/vue.esm.js' //该路径为node_modules下的vue目录 } } // 需要编译器 new Vue({ template: '<div>{{ hi }}</div>' }) // 不需要编译器 new Vue({ render (h) { return h('div', this.hi) } }) 出现警告的原因是使用了template属性。 文文点到为止,详情请直接访问中文官方文档https://cn.vuejs.org/v2/guide/installation.html#对不同构建版本的解释

vue.js开发gulp监听文件变化自动编译

月盾
直接看代码: var gulp = require('gulp') var webpack = require("gulp-webpack"); var webpackConfig = require("./webpack.config.js"); // gulp.task("webpack", function(callback) { // var myConfig = Object.create(webpackConfig); // webpack(myConfig, function(err, stats) { // console.log(">>>>>err:"+JSON.stringify(err)) // console.log(">>>>>stats:"+stats) // if(err) throw new Error("webpack", err); // callback(); // }); // }); /** * 编译时有错误提示 */ gulp.task("webpack", function(){ return gulp.src("./app.js") .pipe(webpack(Object.create(webpackConfig))) .pipe(gulp.dest("./dist/")) }); gulp.watch('./views/*', ['webpack']); webpack.config.js配置 var webpack = require("webpack"); module.exports = { entry: //"./app.js", { app:"./app.js" // vendor: [".