2016-04-07 71 views
1

我正在嘗試使用離子2.0.0-beta.24和小冊子0.7.7來設置一個基本的離子2小冊子應用程序。開始Ionic 2.0.0-beta.24我如何導入node_module css文件without ionic.config.js

ionic start test --v2 --ts 

默認的項目後,如果您打開ionic.config.js文件,你會看到消息

Ionic CLI is no longer responsible for building your web assets, and now 
relies on gulp hooks instead. This file was used for exposing web build 
configuration and is no longer necessary. 
If this file is executed when running ionic commands, then an update to the 
CLI is needed. 

If your version of the Ionic CLI is beta.21 or greater, you can delete this file. 

在老版本的離子2,你會放的目錄,你會想在這個文件中包含像這樣:

sass: { 
    src: ['app/theme/app.+(ios|md).scss'], 
    dest: 'www/build/css', 
    include: [ 
    'node_modules/ionic-framework', 
    'node_modules/ionicons/dist/scss', 
    'node_modules/leaflet/dist' 
    ] 
}, 

現在,我想這是不是一種選擇,讓我怎麼把在CSS樣式表,我需要的,因爲在做出錯,因爲找不到該文件夾​​。

任何幫助將不勝感激。我能夠使用Leaflet js庫,因爲我做到了。

npm install --save leaflet 
typings install --ambient --save leaflet 

地圖加載沒有問題,但瓷磚被加擾,這是一個標誌的CSS表未加載。如果我在樣式表中加入樣式錶鏈接就沒有問題,但我寧願不必依靠CDN。

<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" /> 

謝謝。

+0

http://stackoverflow.com/questions/32265121/gulp-sass-work-around-for-load-path-support的可能重複 – cimmanon

回答

2

所以只是發佈這個問題,它讓我開始追蹤ionic gulp sass-build task的文檔。

他們提供的示例非常有幫助。如果我更新默認gulpfile.js代碼行周圍55來源:

gulp.task('sass', buildSass); 

gulp.task('sass', function(){ 
    return buildSass({ 
    sassOptions: { 
     includePaths: [ 
     'node_modules/ionic-angular', 
     'node_modules/ionicons/dist/scss', 
     'node_modules/leaflet/dist' 
     ] 
    } 
    }) 
}); 

它解決了我的問題。我還需要在需要傳單css的頁面中調用@import "leaflet"