first commit
This commit is contained in:
5
build/node_modules/vulcanize/bin/.eslintrc.json
generated
vendored
Normal file
5
build/node_modules/vulcanize/bin/.eslintrc.json
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"rules": {
|
||||
"no-console": "off"
|
||||
}
|
||||
}
|
||||
154
build/node_modules/vulcanize/bin/vulcanize
generated
vendored
Executable file
154
build/node_modules/vulcanize/bin/vulcanize
generated
vendored
Executable file
@@ -0,0 +1,154 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* @license
|
||||
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
* Code distributed by Google as part of the polymer project is also
|
||||
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
*/
|
||||
|
||||
// jshint node: true
|
||||
'use strict';
|
||||
|
||||
var nopt = require('nopt');
|
||||
var fs = require('fs');
|
||||
var vulcan = require('../lib/vulcan');
|
||||
|
||||
var help = [
|
||||
'vulcanize: Reduce an HTML file and its dependent HTML Imports into one file',
|
||||
'',
|
||||
'Usage:',
|
||||
' vulcanize <html file>',
|
||||
'',
|
||||
'Options:',
|
||||
' -h|--help: print this message',
|
||||
' -v|--version: print version number',
|
||||
' -p <arg>|--abspath <arg>: use <arg> as the "webserver root", make all adjusted urls absolute',
|
||||
' --inline-scripts: Inline external scripts',
|
||||
' --inline-css: Inline external stylesheets',
|
||||
' --add-import <path>: Add this import to the target HTML before vulcanizing. Can be used multiple times.',
|
||||
' --exclude <path>: exclude a subpath from root. Use multiple times to exclude multiple paths. Tags to excluded paths are kept.',
|
||||
' --strip-exclude: Exclude a subpath and strip the link that includes it.',
|
||||
' --strip-comments: Strips all HTML comments not containing an @license from the document',
|
||||
' --redirect <uri>|<path>: Takes an argument in the form of URI|PATH where url is a URI composed of a protocol, hostname, and path and PATH is a local filesystem path to replace the matched URI part with. Multiple redirects may be specified; the earliest ones have the highest priority.',
|
||||
' --no-implicit-strip: DANGEROUS! Avoid stripping imports of the transitive dependencies of imports specified with `--exclude`. May result in duplicate javascript inlining.',
|
||||
' --out-html <path>: If specified, output will be written to <path> instead of stdout.',
|
||||
' --out-request-list <path>: Writes a list of request URLs required to vulcanize <html file> to <path> on success.',
|
||||
' --polymer2: Rewrites urls in accordance with Polymer 2.x expectations, which applies the assetpath property of <dom-module> tags to the url() values in their style elements at runtime. ',
|
||||
'',
|
||||
'Examples:',
|
||||
' The command',
|
||||
'',
|
||||
' vulcanize target.html',
|
||||
'',
|
||||
' will inline the HTML Imports of `target.html` and print the resulting HTML to standard output.',
|
||||
'',
|
||||
' The command',
|
||||
'',
|
||||
' vulcanize target.html > build.html',
|
||||
'',
|
||||
' will inline the HTML Imports of `target.html` and print the result to build.html.',
|
||||
'',
|
||||
' The command',
|
||||
'',
|
||||
' vulcanize -p "path/to/target/" /target.html',
|
||||
'',
|
||||
' will inline the HTML Imports of `target.html`, treat `path/to/target/` as the webroot of target.html, and make all urls absolute to the provided webroot.',
|
||||
'',
|
||||
' The command',
|
||||
'',
|
||||
' vulcanize --exclude "path/to/target/subpath/" --exclude "path/to/target/subpath2/" target.html',
|
||||
'',
|
||||
' will inline the HTML Imports of `target.html` that are not in the directory `path/to/target/subpath` nor `path/to/target/subpath2`.',
|
||||
'',
|
||||
' If the `--strip-excludes` flag is used, the HTML Import `<link>` tags that point to resources in `path/totarget/subpath` and `path/to/target/subpath2/` will also be removed.',
|
||||
'',
|
||||
' The command',
|
||||
'',
|
||||
' vulcanize --inline-scripts target.html',
|
||||
'',
|
||||
' will inline scripts in `target.html` as well as HTML Imports. Exclude flags will apply to both Imports and Scripts.'
|
||||
].join('\n');
|
||||
|
||||
var args = nopt(
|
||||
{
|
||||
help: Boolean,
|
||||
version: Boolean,
|
||||
abspath: String,
|
||||
exclude: [String, Array],
|
||||
polymer2: Boolean,
|
||||
redirect: [String, Array],
|
||||
'add-import': [String, Array],
|
||||
'strip-exclude': [String, Array],
|
||||
'strip-comments': Boolean,
|
||||
'no-implicit-strip': Boolean,
|
||||
'inline-scripts': Boolean,
|
||||
'inline-css': Boolean,
|
||||
'out-html': String,
|
||||
'out-request-list': String
|
||||
},
|
||||
{
|
||||
'h': ['--help'],
|
||||
'v': ['--version'],
|
||||
'p': ['--abspath']
|
||||
}
|
||||
);
|
||||
|
||||
var target = args.argv.remain[0];
|
||||
|
||||
function printHelp() {
|
||||
console.log(help);
|
||||
}
|
||||
|
||||
var pkg = require('../package.json');
|
||||
function printVersion() {
|
||||
console.log('vulcanize:', pkg.version);
|
||||
}
|
||||
|
||||
if (args.version) {
|
||||
printVersion();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (args.help || !target) {
|
||||
printHelp();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// escape a regex string and return a new RegExp
|
||||
function stringToRegExp(str) {
|
||||
return new RegExp(str.replace(/[-\/\\*+?.()|[\]{}]/g, '\\$&'));
|
||||
}
|
||||
|
||||
args.addedImports = args['add-import'] || [];
|
||||
args.excludes = args.exclude || [];
|
||||
args.redirects = args.redirect || [];
|
||||
args.stripExcludes = args['strip-exclude'] || [];
|
||||
args.stripComments = args['strip-comments'];
|
||||
args.implicitStrip = !args['no-implicit-strip'];
|
||||
args.inlineScripts = args['inline-scripts'];
|
||||
args.inlineCss = args['inline-css'];
|
||||
args.polymer2 = args['polymer2'];
|
||||
|
||||
var vulcanize = new vulcan(args);
|
||||
vulcanize.process(target, function(err, content) {
|
||||
if (err) {
|
||||
process.stderr.write(require('util').inspect(err));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (args['out-request-list']) {
|
||||
var urls = Object.keys(vulcanize.loader.requests).filter(function(url) {
|
||||
return !vulcanize.isExcludedHref(url);
|
||||
});
|
||||
fs.writeFileSync(args['out-request-list'], urls.join('\n') + '\n');
|
||||
}
|
||||
|
||||
if (args['out-html']) {
|
||||
fs.writeFileSync(args['out-html'], content + '\n');
|
||||
} else {
|
||||
process.stdout.write(content);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user