rollup-plugin-file
v0.1.1
Published
Rollup plugin to allow a file as an entry point
Downloads
44
Readme
Rollup Plugin File
Rollup plugin to read a file (or vinyl) as an entry, rather than a string.
Installation
npm install --save-dev rollup-plugin-file
Usage
The entry file must have the base
property. Any imports in the entry file will be looked for relative to the base
filepath.
The below is a Gulp example, however it can be used with any file as long as it has the base
property.
import rollupFile from 'rollup-plugin-file';
import rollup from 'rollup';
import gulp from 'gulp';
gulp.task('rollup', function() {
return gulp.src('./src/*.js')
.pipe(through(function(file, enc, done) {
rollup({
entry: file,
plugins: [ rollupFile() ]
})
.then(function(bundle) {
file.contents = new Buffer(bundle.generate(options).code);
done(null, file);
})
.catch(function(err) {
done(err);
});
}))
.pipe(gulp.dest('./dist'));
});
Use gulp-rollup-file
instead of this directly for Gulp, and use alongside gulp-process-inline
to use Rollup with inline <script>
blocks in HTML.
TODO
- Add tests
License
MIT © Simpla