在学vue-loader,按照视频中的做法,
分别新建了一下文件
1 index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<app></app>
<script src="build.js"></script>
</body>
</html>
2 main.js
import Vue from "vue";
3 webpack.config.js
module.exports={
entry:'./main.js',
output:{
path:__dirname,
filename:"build.js"
}
}
4 空的App.vue文件
5 通过npm init后改了scripts为执行的命令
6 通过cnpm install webpack webpack-dev-server下载了webpck webpack-dev-server
最后通过 npm run dev 后,报错如下
ERROR in ./main.js
Module not found: Error: Can't resolve 'vue' in '....vue-loader-demo'
@./main.js 1:0-22
@multi ./~/_webpack-dev-server@2.4.5@webpack-dev-server/client?http://localhost:8081 webpack/hot/dev-server ./main.js
webpack:Failed to compile.
跪谢 各位大神了 在线等
阿神2017-05-19 10:16:31
webpack 就那点配置???
怎么编译vue啊?
弄个vue loader吧
module: {
loaders: [{
test: /\.vue$/,
loader: 'vue'
}]
}
给我你的怀抱2017-05-19 10:16:31
先按照以下两步试试看:
1.本地安装vue-loader依赖
cnpm isntall vue-loader --save-dev
安装成功后,vue-loader-demo文件夹下的package.json,devDependencies项会显示vue-loader和对应的版本号,例如:
"devDependencies": {
"vue-loader": "^11.3.4"
}
2.增添webpack中对vue-loader的配置
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
}
]}