グリッド スタイル、いくつかのスタイラス関数、およびいくつかの変数を配置するcore.stylがあります。このファイルは、すべてのルートにインポートする必要があります。
それに加えて、現在のルートに依存するpage.stylがあります( / contactのcontact.stylなど)
注: 私のプロジェクトは angular.js に基づいているため、html-head はリロードしません。しかし、HTMLヘッドのような角度のあるものをいくつか追加することができます.
フォローしてみた
//index.html
<link rel="stylesheet" href="/css/core.css" /> <-- this is static, always there>
<link rel="stylesheet" href="/css/pages/contact.css" /> <--- added by angular
問題: contact.styl では、スタイラスの変数と関数 (core.styl で宣言) にアクセスできません。
1 つの解決策:各ページのスタイルシートに@import '../core.styl'を追加します。しかし、質問のmeoutのために。
私が試すことができる他の解決策はありますか?
多分そのようなもの(server.js)ですか?
function compile(str, path) {
return stylus(str)
.import(config.path_client + "/css/core")
.set('filename', path)
.set('warn', true)
.set('compress', true);
}
app.use(stylus.middleware({
src: config.path_client + '/css/pages',
compile: compile
}));
編集:私のファイル構造:
|client
||css
|||pages
||||-contact.styl
||||-contact.css
|||base
||||-core.styl
||||-core.css
|server
||-server.js
|