rollup-plugin-fill-html
Advanced tools
Comparing version 1.0.3 to 1.0.5
@@ -159,3 +159,10 @@ 'use strict'; | ||
if (Array.isArray(externals)) { | ||
fileList.splice.apply(fileList, [ fileList.length, 0 ].concat( externals )); | ||
var firstBundle = 0; | ||
externals.forEach(function(node) { | ||
if (node.pos === 'before') { | ||
fileList.splice(firstBundle++, 0, node); | ||
} else { | ||
fileList.splice(fileList.length, 0, node); | ||
} | ||
}); | ||
} | ||
@@ -162,0 +169,0 @@ |
@@ -154,3 +154,10 @@ import fs, { readFileSync, readdirSync, statSync, unlinkSync, writeFileSync } from 'fs'; | ||
if (Array.isArray(externals)) { | ||
fileList.splice.apply(fileList, [ fileList.length, 0 ].concat( externals )); | ||
var firstBundle = 0; | ||
externals.forEach(function(node) { | ||
if (node.pos === 'before') { | ||
fileList.splice(firstBundle++, 0, node); | ||
} else { | ||
fileList.splice(fileList.length, 0, node); | ||
} | ||
}); | ||
} | ||
@@ -157,0 +164,0 @@ |
{ | ||
"name": "rollup-plugin-fill-html", | ||
"version": "1.0.3", | ||
"version": "1.0.5", | ||
"description": "fill html with the bundle file", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
@@ -5,2 +5,6 @@ # rollup-plugin-fill-html | ||
## Note | ||
The 1.0.3 version has been supported to insert css file and external url, you should know that rollup-plugin-fill-html will scan the dest directory and find out the bundl js and `all the css files`, and then into the result html. So you'd better to clean the dest directory before rebuilding, and I think you may need [this](https://github.com/alwaysonlinetxm/rollup-plugin-clean) . | ||
## Installation | ||
@@ -57,3 +61,5 @@ | ||
- format: Optional. when the rollup.config.js use field 'target', then you need to set the format to choose which bundle should be inserted into the result file. | ||
- externals: Optional. a list of files which will be insert into the resule html. The file should be a valid url. | ||
demo: | ||
@@ -75,3 +81,7 @@ | ||
filename: 'index.html', | ||
format: 'es' | ||
format: 'es', | ||
externals: [ | ||
{ type: 'js', file: '//www.test.pajkdc.com/hybridjs/pajk_hybrid_index.0.1.4.js' }, | ||
{ type: 'js', file: '//beacon.test.pajkdc.com/js/beacon.js' } | ||
] | ||
}) | ||
@@ -78,0 +88,0 @@ ] |
@@ -57,3 +57,10 @@ import { statSync, readFileSync, writeFileSync, readdirSync, unlinkSync } from 'fs'; | ||
if (Array.isArray(externals)) { | ||
fileList.splice(fileList.length, 0, ...externals); | ||
let firstBundle = 0; | ||
externals.forEach(function(node) { | ||
if (node.pos === 'before') { | ||
fileList.splice(firstBundle++, 0, node); | ||
} else { | ||
fileList.splice(fileList.length, 0, node); | ||
} | ||
}) | ||
} | ||
@@ -60,0 +67,0 @@ |
18654
409
94