Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
[Issue-94] Use webpack to build vanilla JS bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
nosir committed Sep 15, 2016
1 parent fd32bc7 commit 89b3fe2
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 67 deletions.
16 changes: 1 addition & 15 deletions gulp-tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,6 @@ gulp.task('min-no-mangle', function () {
.pipe(gulp.dest(path.join(paths.dist)));
});

gulp.task('js', function () {
return gulp.src([
path.join(paths.src, paths.build, 'prefix.js'),
path.join(paths.src, 'Cleave.js'),
path.join(paths.src, paths.utils, '**/*.js'),
path.join(paths.src, paths.common, '**/*.js'),
path.join(paths.src, paths.shortcuts, '**/*.js'),
path.join(paths.src, paths.build, 'expose.js'),
path.join(paths.src, paths.build, 'suffix.js')
])
.pipe(concat('cleave.js'))
.pipe(gulp.dest(paths.dist));
});

gulp.task('js:angular', function () {
return gulp.src([
path.join(paths.dist, 'cleave.js'),
Expand All @@ -74,7 +60,7 @@ gulp.task('js:angular', function () {

gulp.task('build', gulpsync.sync([
// sync
'js',
'js:vanilla',
'js:react',
'js:angular',
[
Expand Down
15 changes: 12 additions & 3 deletions gulp-tasks/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@ var paths = {
src: './src/'
};

var entry = 'react.js';
gulp.task('js:vanilla', function () {
return gulp.src(path.join(paths.src + 'Cleave.js'))
.pipe(webpack({
output: {
library: 'Cleave',
libraryTarget: 'umd',
filename: 'cleave.js'
}
}))
.pipe(gulp.dest(paths.dist));
});

gulp.task('js:react', function () {
return gulp.src(path.join(paths.root, entry))
return gulp.src(path.join(paths.root, 'react.js'))
.pipe(webpack({
entry: './src/Cleave.react.js',
output: {
library: 'Cleave',
libraryTarget: 'umd',
Expand Down
20 changes: 9 additions & 11 deletions src/Cleave.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,12 @@ Cleave.prototype = {
}
};

if (typeof module === 'object' && typeof module.exports === 'object') {
Cleave.NumeralFormatter = require('./shortcuts/NumeralFormatter');
Cleave.DateFormatter = require('./shortcuts/DateFormatter');
Cleave.PhoneFormatter = require('./shortcuts/PhoneFormatter');
Cleave.CreditCardDetector = require('./shortcuts/CreditCardDetector');
Cleave.Util = require('./utils/Util');
Cleave.DefaultProperties = require('./common/DefaultProperties');

// CommonJS
module.exports = exports = Cleave;
}
Cleave.NumeralFormatter = require('./shortcuts/NumeralFormatter');
Cleave.DateFormatter = require('./shortcuts/DateFormatter');
Cleave.PhoneFormatter = require('./shortcuts/PhoneFormatter');
Cleave.CreditCardDetector = require('./shortcuts/CreditCardDetector');
Cleave.Util = require('./utils/Util');
Cleave.DefaultProperties = require('./common/DefaultProperties');

// CommonJS
module.exports = Cleave;
21 changes: 0 additions & 21 deletions src/build/expose.js

This file was deleted.

1 change: 0 additions & 1 deletion src/build/prefix.js

This file was deleted.

1 change: 0 additions & 1 deletion src/build/suffix.js

This file was deleted.

5 changes: 2 additions & 3 deletions src/common/DefaultProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,5 @@ var DefaultProperties = {
}
};

if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = exports = DefaultProperties;
}
module.exports = DefaultProperties;

5 changes: 2 additions & 3 deletions src/shortcuts/CreditCardDetector.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,5 @@ var CreditCardDetector = {
}
};

if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = exports = CreditCardDetector;
}
module.exports = CreditCardDetector;

5 changes: 2 additions & 3 deletions src/shortcuts/DateFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,5 @@ DateFormatter.prototype = {
}
};

if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = exports = DateFormatter;
}
module.exports = DateFormatter;

4 changes: 1 addition & 3 deletions src/shortcuts/NumeralFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,4 @@ NumeralFormatter.prototype = {
}
};

if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = exports = NumeralFormatter;
}
module.exports = NumeralFormatter;
5 changes: 2 additions & 3 deletions src/shortcuts/PhoneFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,5 @@ PhoneFormatter.prototype = {
}
};

if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = exports = PhoneFormatter;
}
module.exports = PhoneFormatter;

0 comments on commit 89b3fe2

Please sign in to comment.