Skip to content
This repository was archived by the owner on Jan 4, 2019. It is now read-only.

Commit cb6082d

Browse files
committed
make everything from imports inlined
1 parent 60fd461 commit cb6082d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

vulcan.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if (!options.input) {
3737

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

@@ -173,6 +173,15 @@ function insertImport($, storedPosition, importText) {
173173
pos[operation](importText);
174174
}
175175

176+
function insertInlinedImports($, importText) {
177+
var pos = $('body').last();
178+
var operation = 'prepend';
179+
if (!pos.length) {
180+
pos = $.root();
181+
}
182+
pos[operation](importText);
183+
}
184+
176185
function handleMainDocument() {
177186
var $ = readDocument(options.input);
178187
var dir = path.dirname(options.input);
@@ -213,10 +222,9 @@ function handleMainDocument() {
213222
findScriptLocation($).append(EOL + scripts_after_polymer.join(EOL) + EOL);
214223
}
215224

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

222230
handleMainDocument();

0 commit comments

Comments
 (0)