Пример #1
0
gulp.task('jst', function() {

  return gulp.src(['src/js/Templates/*.html'])

    // Minify the HTML prior to converting to JST
    .pipe(processhtml({ collapseWhitespace: false, removeComments: true, removeCommentsFromCDATA: true }))

    // Convert to JST and assign to app.templates which we'll define once all files are concatenated in
    .pipe(jst({ prepend: 'templates["%s"] = ' }))

    // Concatenate all files together and insert a comma before each newLine
    .pipe(concat('jst.js', { newLine: ',\n' }))

    // Insert the start of an IIFE and variable declarations at the beginning of the file
    .pipe(insert.prepend('(function() {\n_=require("underscore");\nvar templates = {};\n\n'))

    // Insert the end of an IIFE and return the object at the end of the file (also the last function from the jst call will not end with a semicolon, so add one here)
    .pipe(insert.append('\nmodule.exports=templates;\n}).call(this);'))

    // Uglify the JS
    .pipe(uglify())

    .pipe(gulp.dest('require'));
});
Пример #2
0
    return promise.then(function() {
        var promises = [];

        //copy to build folder with copyright header added at the top
        var stream = gulp.src([combineOutput + '/**'])
            .pipe(gulpInsert.prepend(copyrightHeader))
            .pipe(gulp.dest(outputDirectory));

        promises.push(streamToPromise(stream));

        var everythingElse = ['Source/**', '!**/*.js', '!**/*.glsl'];

        if (optimizer === 'uglify2') {
            promises.push(minifyCSS(outputDirectory));
            everythingElse.push('!**/*.css');
        }

        stream = gulp.src(everythingElse, {nodir : true}).pipe(gulp.dest(outputDirectory));
        promises.push(streamToPromise(stream));

        return Promise.all(promises).then(function() {
            rimraf.sync(combineOutput);
        });
    });
Пример #3
0
gulp.task('manifestJs', function () {
    return gulp.src('dist/hash-manifest.json')
        .pipe(insert.prepend('var manifest='))
        .pipe(rename({extname: '.js'}))
        .pipe(gulp.dest('dist'));
});
Пример #4
0
/**
 * @param module {string}
 * @param opts {{isRelease, minify, useBower}}
 */
function buildModule(module, opts) {
  opts = opts || {};
  if (module.indexOf(".") < 0) {
    module = "material.components." + module;
  }
  gutil.log('Building ' + module + (opts.isRelease && ' minified' || '') + ' ...');

  const name = module.split('.').pop();
  utils.copyDemoAssets(name, 'src/components/', 'dist/demos/');

  let stream = utils.filesForModule(module)
      .pipe(filterNonCodeFiles())
      .pipe(filterLayoutAttrFiles())
      .pipe(gulpif('*.scss', buildModuleStyles(name)))
      .pipe(gulpif('*.js', buildModuleJs(name)));

  if (module === 'material.core') {
    stream = splitStream(stream);
  }

  return stream
      .pipe(BUILD_MODE.transform())
      .pipe(insert.prepend(config.banner))
      .pipe(gulpif(opts.minify, buildMin()))
      .pipe(gulpif(opts.useBower, buildBower()))
      .pipe(gulp.dest(BUILD_MODE.outputDir + name));

  function splitStream (stream) {
    const js = series(stream, themeBuildStream())
        .pipe(filter('**/*.js'))
        .pipe(concat('core.js'));

    const css = stream
      .pipe(filter(['**/*.css', '!**/ie_fixes.css']));

    return series(js, css);
  }

  function buildMin() {
    return lazypipe()
        .pipe(gulpif, /.css$/, minifyCss(),
        uglify({ output: { comments: 'some' }})
            .on('error', function(e) {
              console.log('\x07',e.message);
              return this.end();
            }
        )
    )
        .pipe(rename, function(path) {
          path.extname = path.extname
              .replace(/.js$/, '.min.js')
              .replace(/.css$/, '.min.css');
        })
    ();
  }

  function buildBower() {
    return lazypipe()
      .pipe(utils.buildModuleBower, name, VERSION)();
  }

  function buildModuleJs(name) {
    const patterns = [
      {
        pattern: /@ngInject/g,
        replacement: 'ngInject'
      },
      {
        // Turns `thing.$inject` into `thing['$inject']` in order to prevent
        // Closure from stripping it from objects with an @constructor
        // annotation.
        pattern: /\.\$inject\b/g,
        replacement: "['$inject']"
      }
    ];
    return lazypipe()
        .pipe(plumber)
        .pipe(ngAnnotate)
        .pipe(frep, patterns)
        .pipe(concat, name + '.js')
    ();
  }

  function buildModuleStyles(name) {

    let files = [];
    config.themeBaseFiles.forEach(function(fileGlob) {
      files = files.concat(glob(fileGlob, { cwd: ROOT }));
    });

    const baseStyles = files.map(function(fileName) {
      return fs.readFileSync(fileName, 'utf8').toString();
    }).join('\n');

    return lazypipe()
        .pipe(insert.prepend, baseStyles)
        .pipe(gulpif, /theme.scss/, rename(name + '-default-theme.scss'), concat(name + '.scss'))
        // Theme files are suffixed with the `default-theme.scss` string.
        // In some cases there are multiple theme SCSS files, which should be concatenated together.
        .pipe(gulpif, /default-theme.scss/, concat(name + '-default-theme.scss'))
        .pipe(sass)
        .pipe(dedupeCss)
        .pipe(utils.autoprefix)
    (); // Invoke the returning lazypipe function to create our new pipe.
  }

}
Пример #5
0
gulp.task('bin-scripts', function() {
  gulp.src("bin/cli.coffee")
    .pipe(coffee({bare: true}))
    .pipe(insert.prepend('#!/usr/bin/env node\n'))
    .pipe(gulp.dest('bin/'));
});
Пример #6
0
    }, function(file) {

    gulp.src(file.path).pipe(insert.prepend(author_comment))
        .pipe(gulp.dest(file.dirname));
            
    });
Пример #7
0
 gulp.src('./src/fb.css').pipe(minifyCSS()).pipe(tap(function (file,t) {
     var css = file.contents.toString('utf8');
     gulp.src('./src/fb.js').pipe(uglify()).pipe(insert.prepend("var css='"+css+"';")).pipe(gulp.dest('./dist/'));
 }));
Пример #8
0
exports.task = function() {
  var streams = [];
  var modules   = args['modules'],
      overrides = args['override'],
      dest      = args['output-dir'] || config.outputDir,
      filename  = args['filename'] || 'angular-material',
      baseFiles = config.scssBaseFiles,
      scssPipe  = undefined;

  gutil.log("Building css files...");

  // create SCSS file for distribution
  streams.push(
    scssPipe = gulp.src(getPaths())
      .pipe(util.filterNonCodeFiles())
      .pipe(filter(['**', '!**/*-theme.scss']))
      .pipe(filter(['**', '!**/*-print.scss']))
      .pipe(filter(['**', '!**/*-attributes.scss']))
      .pipe(concat('angular-material.scss'))
      .pipe(gulp.dest(dest))                            // raw uncompiled SCSSS
  );

  streams.push(
    scssPipe
          .pipe(sass())
          .pipe(rename({extname: '.css'}))              // unminified
          .pipe(rename({ basename: filename }))
          .pipe(util.autoprefix())
          .pipe(insert.prepend(config.banner))
          .pipe(gulp.dest(dest))
          .pipe(gulpif(!IS_DEV, minifyCss()))
          .pipe(rename({extname: '.min.css'}))
          .pipe(gulp.dest(dest))                        // minified
  );

  // Layout API using Attribute Selectors
  // TO BE Deprecated...

  streams.push(
      gulp.src(config.scssLayoutAttributeFiles)
          .pipe(concat('layouts.scss'))
          .pipe(sass())
          .pipe(util.autoprefix())
          .pipe(rename({ extname : '.css'}))
          .pipe(rename({ prefix  : 'angular-material.'}))
          .pipe(insert.prepend(config.banner))
          .pipe(gulp.dest(dest))
          .pipe(gulpif(!IS_DEV, minifyCss()))
          .pipe(rename({extname: '.min.css'}))
          .pipe(gulp.dest(dest))
  );

  return series(streams);


  function getPaths () {
    var paths = config.scssBaseFiles.slice();
    if ( modules ) {
      paths.push.apply(paths, modules.split(',').map(function (module) {
        return 'src/components/' + module + '/*.scss';
      }));
    } else {
      paths.push('src/components/**/*.scss');
      paths.push('src/core/services/layout/**/*.scss');
    }
    overrides && paths.unshift(overrides);
    return paths;
  }
};
Пример #9
0
 .pipe(foreach(function(stream, file){
   return stream.pipe(insert.prepend('const char PAGE_' + path.parse(file.path).name.toUpperCase() + '[] = R"=====(\n'));
 }))
Пример #10
0
/**
 * @param {boolean} outputCopyright
 */
function prependCopyright(outputCopyright = !useDebugMode) {
    return insert.prepend(outputCopyright ? (copyrightContent || (copyrightContent = fs.readFileSync(copyright).toString())) : "");
}
Пример #11
0
gulp.task('build', function () {
    return gulp.src('lib/run.js')
        .pipe(concat('app.js'))
        .pipe(insert.prepend('#! /usr/bin/env node \r\n\r\n'))
        .pipe(gulp.dest('bin'));
});
Пример #12
0
exports.task = function() {
  var modules   = args['modules'],
      overrides = args['override'],
      dest      = args['output-dir'] || config.outputDir,
      filename  = args['filename'] || 'angular-material',
      paths     = getPaths();
  var streams = [];
  var baseVars = fs.readFileSync('src/core/style/variables.scss', 'utf8').toString();
  gutil.log("Building css files...");
  
  // create SCSS file for distribution
  streams.push(
    gulp.src(paths)
      .pipe(util.filterNonCodeFiles())
      .pipe(filter(['**', '!**/*-theme.scss']))
      .pipe(filter(['**', '!**/standalone.scss']))
      .pipe(concat('angular-material.scss'))
      .pipe(gulp.dest(dest))
  );
  
  streams.push(
      gulp.src(paths)
          .pipe(util.filterNonCodeFiles())
          .pipe(filter(['**', '!**/*-theme.scss']))
          .pipe(filter(['**', '!**/attributes.scss']))
          .pipe(concat('angular-material.scss'))
          .pipe(sass())
          .pipe(rename({ basename: filename }))
          .pipe(util.autoprefix())
          .pipe(insert.prepend(config.banner))
          .pipe(gulp.dest(dest))
          .pipe(gulpif(!IS_DEV, minifyCss()))
          .pipe(rename({extname: '.min.css'}))
          .pipe(gulp.dest(dest))
  );
  streams.push(
      gulp.src(config.scssStandaloneFiles)
          .pipe(insert.prepend(baseVars))
          .pipe(sass())
          .pipe(util.autoprefix())
          .pipe(rename({ basename: "layouts" }))
          .pipe(rename({ prefix: 'angular-material.'}))
          .pipe(insert.prepend(config.banner))
          .pipe(gulp.dest(dest))
          .pipe(gulpif(!IS_DEV, minifyCss()))
          .pipe(rename({extname: '.min.css'}))
          .pipe(gulp.dest(dest))
  );

  return series(streams);


  function getPaths () {
    var paths = config.scssBaseFiles.slice();
    if ( modules ) {
      paths.push.apply(paths, modules.split(',').map(function (module) {
        return 'src/components/' + module + '/*.scss';
      }));
    } else {
      paths.push(path.join(config.paths, '*.scss'));
    }
    overrides && paths.unshift(overrides);
    return paths;
  }
};
Пример #13
0
gulp.task('license', ['build', 'minify'], function () {
  gulp.src('dist/**/*.js')
    .pipe(insert.prepend('/*!\n * MIDI Events ' + packageJSON.version + '\n *\n * @author Mikael Jorhult\n * @license https://github.com/mikaeljorhult/midi-events MIT\n */\n'))
    .pipe(gulp.dest('dist'));
});
Пример #14
0
 * Let's hope this is enough for all our conversion needs, because
 * I strongly prefer to have it happen completely automaticaly.
 */
npmConvert = [
    'gonzales/lib'
    ,'immutable-complex/lib'
];
for(; i<npmConvert.length;i++) {
    module = npmConvert[i];
    gulp.src('./node_modules/' + module +'/*.js')
        // remove the ".js" at the end of the module name.
        //      from: require('./modulename.js')
        //      to:   require('./modulename')
        // requireJS handles a module ending with .js like an url and
        // doesn't find the modules to load anymore. This was done for
        // the gonzales css parser
        .pipe(replace(/(require\(['|"])(.+)(\.js)(['|"]\))/g, function() {
            // see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter
            var val = Array.prototype.slice.call(arguments, 1, -2);
            val.splice(2,1);// this removes the 3rd match, here '.js'
            return val.join('');
        }))
        .pipe(requireConvert())
        .pipe(insert.prepend('/*\n\
 * Don\'t edit this file by hand!\n\
 * This file was generated from a npm-package using gulp. \n\
 * For more information see gulpfile.js in the project root\n\
 */\n'))
        .pipe(gulp.dest('./app/lib/npm_converted/' + module));
}
Пример #15
0
 return function(){
     return gulp.src('fonts/**.scss')
         .pipe(insert.prepend('$fontset-selector: ".fontset";'))
         .pipe(sass().on('error', sass.logError))
         .pipe(gulp.dest('fonts'));
 };
Пример #16
0
gulp.task('coffee', function() {
  gulp.src('./src/*.coffee')
    .pipe(coffee({bare: true}).on('error', gutil.log))
    .pipe(insert.prepend('#!/usr/bin/env node\n'))
    .pipe(gulp.dest('./dist/'))
});
Пример #17
0
gulp.task('insert', function(){
    gulp.src(['app/css/skins/default/color-vars.css'])
        .pipe(insert.append('</style>'))
        .pipe(insert.prepend('<style is=\'custom-style\'>'))
        .pipe(gulp.dest('app/css/skins/default/'));
});
Пример #18
0
gulp.task('examplesCompile', ['collectTargets'], function () {
    if (!paths.examples) {
        return;
    }
    return gulp.src(paths.examples)
        .pipe(flatten())
        .pipe(through.obj(function(file, enc, cb) {
            if (file.isStream()) {
                this.emit('error', 'Streams are not supported!');
                return cb();
            }

            var parentName = file.path.parentPath().basename();
            var basename = file.path.basename();
            var ending = file.path.ending();
            var includePath = file.path.substring(file.path.lastIndexOf('/predefined/'));

            switch (ending) {
                case "md":
                    file.contents = new Buffer("\n"
                        + "## " + parentName + "\n"
                        + "\n"
                        + file.contents + "\n"
                        + "\n"
                    );
                    break;
                case "groovy":
                    file.contents = new Buffer("\n"
                        + "### " + basename + "\n"
                        + "\n"
                        + "```\n"
                        + file.contents + "\n"
                        + "```\n"
                        + "\n"
                        + "```\n"
                        + ":title: Example include of this pre-defined file\n"
                        + "include \"" + includePath + "\"\n"
                        + "```\n"
                        + "\n"
                    );
                    break;
                default:
                    break;
            }

            // make sure the file goes through the next gulp plugin
            this.push(file);
            // tell the stream engine that we are done with this file
            return cb();
        }))
        // make one large example reference file
        .pipe(concat(exampleFile))

        // compile to HTML as in sourceCodeCompile
        // TODO: 100 % copy-paste-code from sourceCodeCompile => refactor
        .pipe(rename({extname: '.md'}))
        .pipe(insert.append("\n\n## Other DSL-References\n\n"))
        .pipe(insert.append(createMdLinks(targetFiles)))
        .pipe(gulp.dest(paths.dest))
        .pipe(markdown({
            highlight: function (code) {
                return highlight.highlight("groovy", code).value;
            },
            renderer: renderer
        }))
        .pipe(rename({extname: '.html'}))

        .pipe(insert.prepend("{% extends 'layout.html' %} {% block toc %} <!-- toc --> {% endblock %} {% block content %}"))
        .pipe(insert.append("{% endblock %}"))
        .pipe(toc())
        .pipe(swig())
        .pipe(gulp.dest(paths.dest));
});
Пример #19
0
gulp.task('concat', () =>
	gulp
	.src([".tmp/config.json", ".tmp/dex-opt-min.js"])
	.pipe(concat('dexecure.js', {newLine: ';'}))
	.pipe(insert.prepend("var dexecure = "))
	.pipe(gulp.dest('.tmp'))
Пример #20
0
gulp.task('sourceCodeCompile', ['layoutCopy', 'collectTargets'], function() {
    return gulp.src(paths.sourceCode)
        .pipe(flatten())
        //.pipe(changed(paths.dest))
        .pipe(docGenPlugin('groovy', {
            // we want the deprecation messages from the javaDoc
            // so we skip all line starting with '@' unless followed by 'deprecated'
            // see http://stackoverflow.com/questions/406230/regular-expression-to-match-string-not-containing-a-word
            'skipCommentLinesMatchingRegex': '^@(?!deprecated).*',
            'commentPostprocessor': function(comment, context) {
                if (!context.followingLineIs('@API', 4) && comment.indexOf('!non-api!') === -1) {
                    // skip blocks which do not have an API annotation, except if they contain "!non-api!"
                    return;
                }

                var result;
                var keyword;

                // extract method or property name from declaration
                if (result = context.followingLineMatches(/^((def|abstract|public|protected|static|final)\s+)*\w+(<[^<>]+>)?\s+(\w+)/, 4)) {
                    keyword = normalizeMemberName(result[result.length - 1]);
                    comment = '## ' + keyword + '\n\n' + comment;
                }

                // convert javaDoc @deprecated and @DeprecatedSince
                if (result = comment.match(/@deprecated (.*)/)) {
                    var deprecatedSinceMatch = context.followingLineMatches(/^@DeprecatedSince\([^\)]*version\s+=\s+(("([^"]*)")|('([^']*)'))[^\)]*\)/, 4);
                    var deprecatedSince = undefined;
                    if (deprecatedSinceMatch) {
                        if (deprecatedSinceMatch[3]) {
                            deprecatedSince = deprecatedSinceMatch[3]
                        }
                        if (deprecatedSinceMatch[5]) {
                            deprecatedSince = deprecatedSinceMatch[5]
                        }
                    }

                    var deprecationWarning = '> %deprecated% This part of the API is marked **deprecated';
                    if (deprecatedSince) {
                        deprecationWarning += ' since version ' + deprecatedSince;
                    }
                    deprecationWarning += '** and will be removed soon.';
                    var deprecationFix = '> %fix% ' + result[1];

                    comment = comment.replace(result[0], deprecationWarning + '\n\n<!-- -->\n\n' + deprecationFix + '\n\n')
                }

                // convert javaDoc links
                while (/(\{@link\s+(\S+\.)*(\w+)(#(\w+)[^\}]*)?\})/.test(comment)) {
                    var link = RegExp.$1
                    var targetType = RegExp.$3
                    var targetMember = RegExp.$5
                    var linkText = targetType;
                    var linkTarget = targetType + '.html';
                    if(targetMember) {
                        targetMember = normalizeMemberName(targetMember);
                        linkText += "#" + targetMember;
                        linkTarget += "#" + targetMember.toLowerCase();
                    }
                    comment = comment.replace(link, reference(linkText, linkTarget))
                }

                // link base class
                if (result = context.followingLineMatches(/((def|abstract|public|static|final)\s+)*class\s+\w+(<[^<>]+>)?\s+extends\s+(\w+)(<[^<>]+>)?/, 4)) {
                    var baseClass = result[result.length - 2]
                    comment += '\n See the [' + baseClass + '](' + baseClass + '.html)-reference for a list of inherited keywords.';
                }

                // extract execution context of the passed closure
                // !!! NOTE: currently supports at most ONE closure as argument !!!
                if (result = context.followingLineMatches(/@DelegatesTo\([^\)]*value\s*=\s*(\w+)[^\)]*\)\s*Closure/, 4)) {
                    comment += '\n See the ' + reference(result[1], result[1] + '.html' ) + '-reference for a list of valid keywords';
                    if(keyword) {
                        comment += ' inside `' + keyword + '`';
                    }
                    comment += '.'
                }

                return comment;
            }

        }))
        .pipe(replace('!non-api!', '> %warning% This part does not belong to the public API and might change without further notice!\n\nDo not use this in production!'))
        .pipe(replace('!since5.1!', '\n\nIntroduced in **Version 5.1**.\n\n'))
        .pipe(replace('!since5.2!', '\n\nIntroduced in **Version 5.2**.\n\n'))
        .pipe(replace('!since5.3!', '\n\nIntroduced in **Version 5.3**.\n\n'))
        .pipe(replace('!since5.4!', '\n\nIntroduced in **Version 5.4**.\n\n'))
        .pipe(replace('!since5.5!', '\n\nIntroduced in **Version 5.5**.\n\n'))
        .pipe(replace('!since5.6!', '\n\nIntroduced in **Version 5.6**.\n\n'))
        .pipe(replace('!since5.7!', '\n\nIntroduced in **Version 5.7**.\n\n'))
        .pipe(rename({extname: '.md'}))
        .pipe(insert.append("\n\n## Other DSL-References\n\n"))
        .pipe(insert.append(createMdLinks(targetFiles)))
        .pipe(gulp.dest(paths.dest))
        .pipe(markdown({
            highlight: function (code) {
                return highlight.highlight("groovy", code).value;
            },
            renderer: renderer
        }))
        .pipe(rename({extname: '.html'}))

        .pipe(insert.prepend("{% extends 'layout.html' %} {% block toc %} <!-- toc --> {% endblock %} {% block content %}"))
        .pipe(insert.append("{% endblock %}"))
        .pipe(toc())
        .pipe(swig())
        .pipe(gulp.dest(paths.dest));
});
Пример #21
0
exports.task = function() {
  const streams = [];
  const modules   = args.modules,
      overrides = args.override,
      dest      = args['output-dir'] || config.outputDir,
      layoutDest= dest + 'layouts/';

  gutil.log("Building css files...");

  // create SCSS file for distribution
  streams.push(
    gulp.src(getPaths())
      .pipe(util.filterNonCodeFiles())
      .pipe(filter(['**', '!**/*.css']))
      .pipe(filter(['**', '!**/*-theme.scss']))
      .pipe(filter(['**', '!**/*-attributes.scss']))
      .pipe(concat('angular-material.scss'))
      .pipe(gulp.dest(dest))            // raw uncompiled SCSS
      .pipe(sass())
      .pipe(util.dedupeCss())
      .pipe(util.autoprefix())
      .pipe(insert.prepend(config.banner))
      .pipe(gulp.dest(dest))                        // unminified
      .pipe(gulpif(!IS_DEV, minifyCss()))
      .pipe(gulpif(!IS_DEV, util.dedupeCss()))
      .pipe(rename({extname: '.min.css'}))
      .pipe(gulp.dest(dest))                        // minified
  );

  streams.push(
      gulp.src( config.cssIEPaths.slice() )         // append raw CSS for IE Fixes
        .pipe( concat('angular-material.layouts.ie_fixes.css') )
        .pipe( gulp.dest(layoutDest) )
  );

  // Generate standalone SCSS (and CSS) file for Layouts API
  // The use of these classnames is automated but requires
  // the Javascript module module `material.core.layout`
  //  > (see src/core/services/layout.js)
  // NOTE: this generated css is ALSO appended to the published
  //       angular-material.css file

  streams.push(
    gulp.src(config.scssLayoutFiles)
        .pipe(concat('angular-material.layouts.scss'))
        .pipe(sassUtils.hoistScssVariables())
        .pipe(insert.prepend(config.banner))
        .pipe(gulp.dest(layoutDest))      // raw uncompiled SCSS
        .pipe(sass())
        .pipe(util.dedupeCss())
        .pipe(util.autoprefix())
        .pipe(rename({ extname : '.css'}))
        .pipe(gulp.dest(layoutDest))
        .pipe(gulpif(!IS_DEV, minifyCss()))
        .pipe(gulpif(!IS_DEV, util.dedupeCss()))
        .pipe(rename({extname: '.min.css'}))
        .pipe(gulp.dest(layoutDest))
  );

  // Generate the Layout-Attributes SCSS and CSS files
  // These are intended to allow usages of the Layout styles
  // without:
  //  * use of the Layout directives and classnames, and
  //  * Layout module `material.core.layout

  streams.push(
      gulp.src(config.scssLayoutAttributeFiles)
          .pipe(concat('angular-material.layout-attributes.scss'))
          .pipe(sassUtils.hoistScssVariables())
          .pipe(gulp.dest(layoutDest))     // raw uncompiled SCSS
          .pipe(sass())
          .pipe(util.dedupeCss())
          .pipe(util.autoprefix())
          .pipe(rename({ extname : '.css'}))
          .pipe(insert.prepend(config.banner))
          .pipe(gulp.dest(layoutDest))
          .pipe(gulpif(!IS_DEV, minifyCss()))
          .pipe(gulpif(!IS_DEV, util.dedupeCss()))
          .pipe(rename({extname: '.min.css'}))
          .pipe(gulp.dest(layoutDest))
  );

  return series(streams);


  function getPaths () {
    const paths = config.scssBaseFiles.slice();
    if ( modules ) {
      paths.push.apply(paths, modules.split(',').map(function (module) {
        return 'src/components/' + module + '/*.scss';
      }));
    } else {
      paths.push('src/components/**/*.scss');
      paths.push('src/core/services/layout/**/*.scss');
    }
    overrides && paths.unshift(overrides);
    return paths;
  }
};
Пример #22
0
gulp.task('insert', function(){
    gulp.src(['app/css/skins/default/color-vars-body.css',
              'app/css/skins/default/color-vars.css'])
        .pipe(insert.append('</style>'))
        .pipe(insert.prepend("<style is=\"custom-style\">"));
});
function buildModule(module, isRelease) {
  if ( module.indexOf(".") < 0) {
    module = "material.components." + module;
  }

  var name = module.split('.').pop();
  gutil.log('Building ' + module + (isRelease && ' minified' || '') + ' ...');

  utils.copyDemoAssets(name, 'src/components/', 'dist/demos/');

  return utils.filesForModule(module)
    .pipe(filterNonCodeFiles())
    .pipe(gulpif('*.scss', buildModuleStyles(name)))
    .pipe(gulpif('*.js', buildModuleJs(name)))
    .pipe(BUILD_MODE.transform())
    .pipe(insert.prepend(config.banner))
    .pipe(gulpif(isRelease, buildMin()))
    .pipe(gulp.dest(BUILD_MODE.outputDir + name));


  function buildMin() {
    return lazypipe()
      .pipe(gulpif, /.css$/, minifyCss(),
        uglify({ preserveComments: 'some' })
          .on('error', function(e) {
            console.log('\x07',e.message);
            return this.end();
          }
        )
      )
      .pipe(rename, function(path) {
        path.extname = path.extname
          .replace(/.js$/, '.min.js')
          .replace(/.css$/, '.min.css');
      })
      .pipe(utils.buildModuleBower, name, VERSION)
      ();
  }

function buildModuleJs(name) {
  return lazypipe()
    .pipe(plumber)
    .pipe(ngAnnotate)
    .pipe(concat, name + '.js')
    ();
}

function buildModuleStyles(name) {
  var files = [];
  config.themeBaseFiles.forEach(function(fileGlob) {
    files = files.concat(glob(fileGlob, { cwd: __dirname }));
  });
  var baseStyles = files.map(function(fileName) {
    return fs.readFileSync(fileName, 'utf8').toString();
  }).join('\n');

  return lazypipe()
    .pipe(insert.prepend, baseStyles)
    .pipe(gulpif, /theme.scss/,
      rename(name + '-default-theme.scss'), concat(name + '.scss')
    )
    .pipe(sass)
    .pipe(autoprefix)
    (); // invoke the returning fn to create our pipe
}

}
Пример #24
0
gulp.task('cache-bust', function () {
  var cacheBust = "var systemLocate = System.locate; System.locate = function(load) { var cacheBust = '?bust=' + '" + gittag +"'; return Promise.resolve(systemLocate.call(this, load)).then(function(address) { if (address.indexOf('bust') > -1 || address.indexOf('css') > -1 || address.indexOf('json') > -1) return address; return address + cacheBust; });}\n"
  return gulp.src('dist/app/app.js')
      .pipe(insert.prepend(cacheBust))
      .pipe(gulp.dest('dist/app'));
});