2.2.0 • Published 7 years ago

gulp-export v2.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

Gulp Export Plugin

Export files through index.js

Install

$ npm install gulp-export

Usage

Let's we have the next file structure

|   .gitignore
|   gulpfile.js
|   jsconfig.json
|   LICENSE
|   package.json
|   README.md
|
\---src
    |   Class1.js
    |   Class1.map
    |   Class2.js
    |   utils1.jsx
    |   _exclude.js
    |
    \---Namespace
            Class4.js
            Class5.js
            utils2.jsx
            _exclude.js

The module exports the files to a single file

// ./build/index.js
import _Class1 from './Class1';
import _Class2 from './Class1';
import * as _utils1 from './utils1';

import _NamespaceClass4 from './Namespace/Class4';
import _NamespaceClass5 from './Namespace/Class5';
import * as _namespaceUtils2 from './Namespace/utils2';

export default {
    'Class1': _Class1,
    'Class2': _Class2,
    'utils1': utils1,
    'NamespaceClass4': NamespaceClass4,
    'NamespaceClass5': NamespaceClass5,
    'namespaceUtils2': namespaceUtils2
};

gulpfile.js

'use strict';

const sourceDir = './src';
const buildDir = './build';

const Del = require('del');
const Gulp = require('gulp');
const ESLlint = require('gulp-eslint');
const Sourcemaps = require('gulp-sourcemaps');
const Export = require('gulp-export');
const Babel = require('gulp-babel');

Gulp.task('clean', cb => {
  return Del([buildDir], cb);
});

Gulp.task('js-compile', ['clean'], function() {
  return Gulp.src([`${sourceDir}/**/*.js`])
    .pipe(ESLlint())
    .pipe(ESLlint.format())
    .pipe(ESLlint.failAfterError())
    .pipe(Export({
        context: './src',
        exclude: /_/,           // excluded all files with underscore
        exportType: 'default',  // export as default can be: named, default and global
    }))
    .pipe(Sourcemaps.init())
    .pipe(Babel())
    .pipe(Sourcemaps.write('.'))
    .pipe(Gulp.dest(buildDir));
});

gulp.task('default', ['js-export']);

License

The MIT License Copyright (c) 2015-present Ivan Zakharchenko

2.2.0

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

9 years ago

0.0.1

9 years ago