试图用 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
模块添加到眼镜中?