尝试使用gulp清理我的Rails资产管道。厌倦了将每个npm包scss / css文件显式添加到includePaths。我已经彻底搜索并阅读了文档,但我仍然无法让Eyeglass找到我的node_modules。
这是我到目前为止的设置:
var sassPaths = [
'./app/assets/stylesheets/*',
publicAssets + '/stylesheets',
'./node_modules/magic.css/1.1.0/',
'./node_modules/colors.css/sass/'
],
sassOptions = {
indentedSyntax: true,
sourceComments: true,
errLogToConsole: true,
includePaths: sassPaths,
eyeglass: {
enableImportOnce: false,
buildDir: publicAssets + '/stylesheets',
assets: {
// prefix to give assets for their output url.
httpPrefix: "assets",
installer: function(assetFile, assetUri, oldInstaller, cb) {
// oldInstaller is the standard eyeglass installer in this case.
// We proxy to it for logging purposes.
oldInstaller(assetFile, assetUri, function(err, result) {
if (err) {
console.log("Error installing '" + assetFile + "': " + err.toString());
} else {
console.log("Installed Asset '" + assetFile + "' => '" + result + "'");
}
cb(err, result);
});
},
// Add assets except for js and sass files
// The url passed to asset-url should be
// relative to the assets directory specified.
sources: [{
directory: './node_modules/',
pattern: [
'**/dist/*',
'**/dist/{scss,sass,css}/*',
'**/{scss,sass,css}/*',
'**/*.{scss, sass, css}',
'**/{scss,sass,css}/*'
],
globOpts: { ignore: ["**/*.js"], root: '.', }
}]
},
importer: function(uri, prev, done) {
done(sass.compiler.types.NULL);
}
}
},
eyeglass = new Eyeglass(sassOptions);
console.log(eyeglass.modules);
console.log(eyeglass.assets.assetPath);
stream = gulp.src(sassSource)
.pipe(sourceMaps.init())
.pipe(sass(eyeglass.options).on("error", sass.logError))
.pipe(postcss([lost(), autoprefixer({ browsers: ['last 2 versions'] }) ]));
我试图将Eyeglass指向'./node_modules'
路径并使用模式数组让它正确解析已安装的软件包以便导入css / scss。当我查看文档时,甚至不必用模式来指导它,但是一旦你将它指向正确的目录它就会知道在哪里看。
是否有一种简单的方法可以将所有--save-dev
模块添加到眼镜中?