Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
make everything from imports inlined
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Aug 30, 2013
1 parent 25d0a2f commit 1404fe4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions vulcanize/vulcan.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if (!options.input) {

var DEFAULT_OUTPUT = 'vulcanized.html';
if (!options.output) {
console.warn('Default output to index-vulcanized.html' + (options.csp ? ', vulcanized.js,' : '') + ' and vulcanized.html in the input directory.');
console.warn('Default output to vulcanized.html' + (options.csp ? ' and vulcanized.js' : '') + ' in the input directory.');
options.output = path.resolve(path.dirname(options.input), DEFAULT_OUTPUT);
}

Expand Down Expand Up @@ -173,6 +173,15 @@ function insertImport($, storedPosition, importText) {
pos[operation](importText);
}

function insertInlinedImports($, importText) {
var pos = $('body').last();
var operation = 'prepend';
if (!pos.length) {
pos = $.root();
}
pos[operation](importText);
}

function handleMainDocument() {
var $ = readDocument(options.input);
var dir = path.dirname(options.input);
Expand Down Expand Up @@ -213,10 +222,9 @@ function handleMainDocument() {
findScriptLocation($).append(EOL + scripts_after_polymer.join(EOL) + EOL);
}

fs.writeFileSync(options.output, output, 'utf8');
imports_before_polymer.push('<link rel="import" href="' + path.basename(options.output) + '">');
insertImport($, import_pos, imports_before_polymer.join(EOL) + EOL);
fs.writeFileSync(path.resolve(outputDir, 'index-vulcanized.html'), $.html(), 'utf8');
insertInlinedImports($, output);
fs.writeFileSync(options.output, $.html(), 'utf8');
}

handleMainDocument();

0 comments on commit 1404fe4

Please sign in to comment.