安装vue package (运行时依赖)
npm --save install vue
runtime-only 错误提示:它的意思是说当前是runtime-only无法编译模板,这里我们需要使用runtime-compiler,使用runtime-only使用的是vue.runtime.js文件,无法编译模板,所以需要修改成使用runtime-compiler(vue.esm.js文件)
解决方案有两种:
第一种是直接以入该文件:
import Vue from "vue/dist/vue.esm.js"
第二种是在webpack.config.js中给vue配置一个别名,这样引入的时候就会通过别名来引入该vue.esm.js文件
resolve: {
alias: {
"vue$": "vue/dist/vue.esm.js"
}
}
安装vue loader
npm install --save-dev vue-loader vue-template-compiler
vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.
官方给的说明 :https://vue-loader.vuejs.org/zh/migrating.html
// webpack.config.js
const VueLoaderPlugin = require('vue-loader/lib/plugin')
module.exports = {
// ...
plugins: [
new VueLoaderPlugin()
]
}
webpack 打包时分离 vue 引用的 css 文件
npm install extract-text-webpack-plugin --save-dev
安装html-webpack-plugin 出现这个问题是版本的问题 ,重新安装3.2.0版本即可
TypeError: Cannot read property ‘make’ of undefined
npm install --save-dev html-webpack-plugin@3.2.0
由于 UglifyjsWebpackPlugin版本导致的问题
TypeError: Cannot read property ‘compilation’ of undefined
安装 1.0.0版本即可
npm install --save-dev uglifyjs-webpack-plugin@1.0.0