Esempio n. 1
0
var compile = module.exports = function( content, file, opts ) {

    if ( isSassSyntax( content, file ) ) {
        content = sass.sass2scss( content );
    }

    cache = {};
    opts.data = before( content, file, unique( opts.include_paths ) );
    content = sass.renderSync( opts );
    content = after( content, file, opts.include_paths );

    return content;
};
Esempio n. 2
0
    return _process( content ).replace( map.reg, function( all, value ) {
        var file = lookup( value, ext, paths ),
            content;

        if ( file ) {

            // 已经在堆里面了
            if ( stack[ file.realpath ] ) {
                fis.log.error( 'can\'t embed file ' + file.basename + '.' );
            }

            // 如果已经引入过了,就不再引入。
            // 类似与include_once.
            if ( cache[ file.realpath ] ) {
                return '';
            }

            // 有可能当前文件并没有经过 fis 的compile,以至于没有 cahce 对象。
            if (currentFile.cache) {
                currentFile.cache.addDeps(file.realpath);
            }

            stack[ file.realpath ] = true;
            cache[ file.realpath ] = true;

            content = file.getContent();
            if ( isSassSyntax( content, file ) ) {
                content = sass.sass2scss( content );
            }

            content = before( content, file, [ file.dirname ].concat( paths ) );

            delete stack[ file.realpath ];

            return content;

        } else {
            fis.log.error( value + ' not found!' );
            return '';
        }
    });