rollup-plugin-file

0.1.1 • Public • Published

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

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i rollup-plugin-file

    Weekly Downloads

    7

    Version

    0.1.1

    License

    MIT

    Last publish

    Collaborators

    • bede
    • seaneking