Html yeoman webapp子文件夹错误的css路径
我正在使用yeoman webapp generator(0.5.0),我的应用程序目录如下所示:Html yeoman webapp子文件夹错误的css路径,html,css,web-applications,gruntjs,yeoman,Html,Css,Web Applications,Gruntjs,Yeoman,我正在使用yeoman webapp generator(0.5.0),我的应用程序目录如下所示: app/ ├── dir1 │ └── index.html ├── favicon.ico ├── images ├── index.html ├── robots.txt ├── scripts │ └── main.js └── styles └── main.css 在dir1/index.html中,我刚刚复制了app/index.html的内容,并修改了css和js文
app/
├── dir1
│ └── index.html
├── favicon.ico
├── images
├── index.html
├── robots.txt
├── scripts
│ └── main.js
└── styles
└── main.css
在dir1/index.html
中,我刚刚复制了app/index.html
的内容,并修改了css和js文件的路径。
例如来自
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="styles/main.css">
正确的路径应该是:
http://127.0.0.1/webapp/styles/9c307a9d.vendor.css
http://127.0.0.1/webapp/styles/84f823a4.main.css
http://127.0.0.1/webapp/scripts/db02b173.vendor.js
http://127.0.0.1/webapp/scripts/cb7562c6.plugins.js
http://127.0.0.1/webapp/scripts/b6c3df09.main.js
问题是一些grunt任务使用dir1
作为根目录而不是父目录
如何解决此问题?更改为相对站点,而不是相对路径
<link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="/styles/main.css">
我发现了如何解决这个问题! 在
dir1/index.html
中,我不仅要更改外部文件(css、js)的相对路径,还要更改grunt块,例如代码:
应修改为:
谢谢,但这并不能解决我的问题。运行
grunt build
后,路径再次成为相对路径
http://127.0.0.1/webapp/styles/9c307a9d.vendor.css
http://127.0.0.1/webapp/styles/84f823a4.main.css
http://127.0.0.1/webapp/scripts/db02b173.vendor.js
http://127.0.0.1/webapp/scripts/cb7562c6.plugins.js
http://127.0.0.1/webapp/scripts/b6c3df09.main.js
<link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="/styles/main.css">