1.0.4 • Published 4 years ago

advanced-js-import v1.0.4

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

INSTALL

npm install advanced-js-import --save-dev

USAGE

First, install advanced-js-import as a devDependency:

Then add it to the gulpfile.js:

var gulp = require('gulp');
var jsImport = require('advanced-js-import');

gulp.task('import', function() {
  return gulp.src('index.js')
        .pipe(jsImport({
            hideConsole: true,
            importStack: true
        }))
        .pipe(gulp.dest('dist'));
});

Final, run import task where you need, eg: gulp import

DEMO

you can get all code here

Use of Commented import files

Please use "// " with space for comment @import or ES6 import like below example "// @import 'bootstrap.js';" or "// import 'bootstrap.js';"

File Tree

this is the file tree:

demo
|
-- widget
|   |
|   -- widget.js
|   |
|   -- config.js
|   
-- index.js
|   
-- gulpfile.js
|   
-- package.json

Brief Intorduce

index.js:

// index.js

@import './widget/widget.js'

output(config);

// index.js end

in index.js, you can use @import 'xxx.js' when you want import a js file

Run

Enter the demo directory in command

cd demo

Install gulp advanced-js-import

gulp install

Compile files

gulp import

You could see a js file dist/index.js like this:

// index.js
// widget.js
// config.js
var config = 'this is config value';
// config.js end

function output(str) {
  console.log(str);
}
// widget.js end

output(config);
// index.js end
1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago