我使用的是自耕農webapp生成(0.5.0)和我的應用程序目錄的樣子:自耕農webapp的子文件夾錯誤的CSS路徑
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">
到
<link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="../styles/main.css">
使用grunt serve
一切正常,但是當我用grunt build
建立dir1/index.html
的路徑是錯誤的。從Chrome開發者控制檯,我可以看到一些錯誤:
GET http://127.0.0.1/webapp/dir1/styles/9c307a9d.vendor.css 127.0.0.1/:1
GET http://127.0.0.1/webapp/dir1/styles/84f823a4.main.css 127.0.0.1/:1
GET http://127.0.0.1/webapp/dir1/scripts/db02b173.vendor.js (index):3
GET http://127.0.0.1/webapp/dir1/scripts/cb7562c6.plugins.js (index):8
GET http://127.0.0.1/webapp/dir1/scripts/b6c3df09.main.js (index):8
正確的路徑應該是:
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
的問題是,一些繁重的任務使用dir1
的根目錄,而不是父目錄。
我該如何解決這個問題?
謝謝,但它不能解決我的問題。運行'grunt build'之後,路徑又變成了相對的 – Lorenzo 2014-10-01 17:20:10