-
Install the module with:
npm install gulp-pure-cjs --save-dev
-
Add a task to your
Gulpfile.js
:
var pure = require('gulp-pure-cjs');
gulp.task('build', function() {
return gulp.src('./lib/index.js')
.pipe(pure({
exports: 'my-exported-module'
}))
.pipe(gulp.dest('dist'));
});
pure-cjs
always re-read files from disk, so if you load other plugin in pipeline that
changes file content, this changes will be lost!
In order to produce sourcemaps, you have to use gulp-sourcemaps plugin. This allow source modification info to be preserved through your pipeline, from
where you call sourcemaps.init
to where you call sourcemaps.write
.
See gulp-sourcemaps
project for more info about out it works.
var sourcemaps = require('gulp-sourcemaps');
...
return gulp.src('./test/example_test.js')
.pipe(sourcemaps.init())
...
.pipe(pure())
...
.pipe(sourcemaps.write('.'))
...
The options object you use to call the plugin is passed to pure-cjs transform method with some change:
dryRun
is always set to true, in order to disable pure-cjs output file saveinput
is overwritten with filename received from gulp pipeline
For documentation on all other options available, see pure-cjs repo
- documentation - maybe I will add documentation if you ask it. Open an issue for this.
- support - open an issue here.
MIT © 2014, Andrea Parodi