- 一个php项目中嵌入一个前端的vuejs项目,项目的目录如下:
.
├── app
├── debug.log
├── node_modules
├── nodemon.json
├── package.json
├── phpunit.xml
├── public
│ ├── index.html
│ ├── index.php
│ ├── mix-manifest.json
│ ├── robots.txt
│ └── static
├── readme.md
├── resources
│ ├── README.md
│ ├── build
│ ├── config
│ ├── index.html
│ ├── src
│ └── static
├── routes
│ ├── api.php
│ ├── channels.php
│ ├── console.php
│ └── web.php
├── server.php
└── yarn.lock
项目的结构是这样的,package.json和node_modules 都是放在了项目的根目录下,resources目录下放着前端的vue项目代码。目的是实现在项目根目录下运行npm run build
将js css index.html 文件 打包到public 文件下。
- 问题是:
在项目的跟目录下运行npm run dev
总是报错,后台把webpack.dev.conf.js 中的
new HtmlWebpackPlugin({
filename: 'index.html',
template: './resources/index.html',
inject: true
}),
hmtl-webpack-plugin插件的template由原来的‘index.html’改为'./resources/index.html',才工作正常,现在是可以正常的开发和打包了,但是不清楚为什么需要时改template 的文件路径,template的文件路径需要相对于那个目录?
启动nodejs服务器的目录