parent
5266bc8551
commit
17f02466c2
|
@ -24,6 +24,7 @@ var gulp = require('gulp');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var merge = require('merge-stream');
|
var merge = require('merge-stream');
|
||||||
var $ = require('gulp-load-plugins')();
|
var $ = require('gulp-load-plugins')();
|
||||||
|
var uniffe = require('./utils/uniffe.js');
|
||||||
var del = require('del');
|
var del = require('del');
|
||||||
var vinylPaths = require('vinyl-paths');
|
var vinylPaths = require('vinyl-paths');
|
||||||
var runSequence = require('run-sequence');
|
var runSequence = require('run-sequence');
|
||||||
|
@ -217,11 +218,12 @@ gulp.task('scripts', ['jscs', 'jshint'], function() {
|
||||||
'src/ripple/ripple.js'
|
'src/ripple/ripple.js'
|
||||||
];
|
];
|
||||||
return gulp.src(sources)
|
return gulp.src(sources)
|
||||||
|
.pipe(uniffe())
|
||||||
.pipe($.sourcemaps.init())
|
.pipe($.sourcemaps.init())
|
||||||
// Concatenate Scripts
|
// Concatenate Scripts
|
||||||
.pipe($.concat('material.js'))
|
.pipe($.concat('material.js'))
|
||||||
.pipe($.iife({
|
.pipe($.iife({
|
||||||
useStrict: false,
|
useStrict: true,
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest('./dist'))
|
.pipe(gulp.dest('./dist'))
|
||||||
// Minify Scripts
|
// Minify Scripts
|
||||||
|
|
|
@ -7,12 +7,14 @@
|
||||||
"author": "Google",
|
"author": "Google",
|
||||||
"repository": "google/material-design-lite",
|
"repository": "google/material-design-lite",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"acorn": "^2.2.0",
|
||||||
"apache-server-configs": "^2.7.1",
|
"apache-server-configs": "^2.7.1",
|
||||||
"browser-sync": "^2.2.3",
|
"browser-sync": "^2.2.3",
|
||||||
"chai": "^2.0.0",
|
"chai": "^2.0.0",
|
||||||
"chai-jquery": "^2.0.0",
|
"chai-jquery": "^2.0.0",
|
||||||
"del": "^1.1.1",
|
"del": "^1.1.1",
|
||||||
"drool": "^0.2.1",
|
"drool": "^0.2.1",
|
||||||
|
"escodegen": "^1.6.1",
|
||||||
"gulp": "^3.8.11",
|
"gulp": "^3.8.11",
|
||||||
"gulp-autoprefixer": "^2.0.0",
|
"gulp-autoprefixer": "^2.0.0",
|
||||||
"gulp-cache": "^0.2.6",
|
"gulp-cache": "^0.2.6",
|
||||||
|
@ -61,7 +63,7 @@
|
||||||
"require-dir": "^0.3.0",
|
"require-dir": "^0.3.0",
|
||||||
"run-sequence": "^1.0.2",
|
"run-sequence": "^1.0.2",
|
||||||
"swig": "^1.4.2",
|
"swig": "^1.4.2",
|
||||||
"through2": "^0.6.3",
|
"through2": "^2.0.0",
|
||||||
"vinyl-paths": "^1.0.0"
|
"vinyl-paths": "^1.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Material Design Lite
|
||||||
|
* Copyright 2015 Google Inc. All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var through = require('through2');
|
||||||
|
var escodegen = require('escodegen');
|
||||||
|
var acorn = require('acorn');
|
||||||
|
|
||||||
|
function uniffe(contents) {
|
||||||
|
var comments = [];
|
||||||
|
var tokens = [];
|
||||||
|
|
||||||
|
var ast = acorn.parse(contents, {
|
||||||
|
ranges: true,
|
||||||
|
onComment: comments,
|
||||||
|
onToken: tokens
|
||||||
|
});
|
||||||
|
|
||||||
|
escodegen.attachComments(ast, comments, tokens);
|
||||||
|
|
||||||
|
if (ast.body[0].expression.callee === undefined) {
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rootProgram = ast.body[0].expression.callee.body;
|
||||||
|
|
||||||
|
rootProgram.type = 'Program';
|
||||||
|
// drop use strict
|
||||||
|
rootProgram.body = rootProgram.body.slice(1);
|
||||||
|
// attach all leading comments from outside iffe
|
||||||
|
rootProgram.leadingComments = ast.body[0].leadingComments;
|
||||||
|
|
||||||
|
return escodegen.generate(rootProgram, {comment: true});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = function() {
|
||||||
|
return through.obj(function(file, enc, cb) {
|
||||||
|
if (file.isBuffer()) {
|
||||||
|
file.contents = new Buffer(uniffe(file.contents.toString(enc)), enc);
|
||||||
|
}
|
||||||
|
|
||||||
|
cb(null, file);
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in New Issue