Add umd distribution builds via webpack
This commit is contained in:
parent
272bea702a
commit
89d32316b6
@ -1,6 +1,7 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
## [unreleased]
|
## [unreleased]
|
||||||
|
* Add umd distribution builds via webpack. (https://github.com/aaronjensen/updeep/issues/3)
|
||||||
|
|
||||||
## [0.2.2]
|
## [0.2.2]
|
||||||
* Fix `Object.isFrozen` breaking on null in chrome. (https://github.com/aaronjensen/updeep/pull/5)
|
* Fix `Object.isFrozen` breaking on null in chrome. (https://github.com/aaronjensen/updeep/pull/5)
|
||||||
|
37
createWebpackConfig.js
Normal file
37
createWebpackConfig.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
'use strict'; /* eslint strict:0, no-var:0, func-names:0 */
|
||||||
|
var webpack = require('webpack');
|
||||||
|
|
||||||
|
module.exports = function createWebpackConfig(options) {
|
||||||
|
var config = {
|
||||||
|
plugins: [
|
||||||
|
new webpack.optimize.OccurrenceOrderPlugin(),
|
||||||
|
],
|
||||||
|
|
||||||
|
module: {
|
||||||
|
loaders: [
|
||||||
|
{ test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/ },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
output: {
|
||||||
|
library: 'updeep',
|
||||||
|
libraryTarget: 'umd',
|
||||||
|
},
|
||||||
|
|
||||||
|
resolve: {
|
||||||
|
extensions: ['', '.js'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
config.output.filename = options.filename;
|
||||||
|
|
||||||
|
if (options.minify) {
|
||||||
|
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
|
||||||
|
compressor: {
|
||||||
|
screw_ie8: true,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
return config;
|
||||||
|
};
|
41
gulpfile.js
41
gulpfile.js
@ -1,13 +1,17 @@
|
|||||||
'use strict'; /* eslint strict:0, no-var:0, func-names:0 */
|
'use strict'; /* eslint strict:0, no-var:0, func-names:0 */
|
||||||
var gulp = require('gulp');
|
var gulp = require('gulp');
|
||||||
|
|
||||||
|
var babel = require('gulp-babel');
|
||||||
|
var batch = require('gulp-batch');
|
||||||
var eslint = require('gulp-eslint');
|
var eslint = require('gulp-eslint');
|
||||||
var excludeGitignore = require('gulp-exclude-gitignore');
|
var excludeGitignore = require('gulp-exclude-gitignore');
|
||||||
var mocha = require('gulp-mocha');
|
var mocha = require('gulp-mocha');
|
||||||
var nsp = require('gulp-nsp');
|
var nsp = require('gulp-nsp');
|
||||||
var babel = require('gulp-babel');
|
|
||||||
var watch = require('gulp-watch');
|
|
||||||
var batch = require('gulp-batch');
|
|
||||||
var rimraf = require('rimraf');
|
var rimraf = require('rimraf');
|
||||||
|
var watch = require('gulp-watch');
|
||||||
|
var webpack = require('webpack-stream');
|
||||||
|
|
||||||
|
var createWebpackConfig = require('./createWebpackConfig.js');
|
||||||
|
|
||||||
// Initialize the babel transpiler so ES2015 files gets compiled
|
// Initialize the babel transpiler so ES2015 files gets compiled
|
||||||
// when they're loaded
|
// when they're loaded
|
||||||
@ -34,7 +38,7 @@ gulp.task('test', function() {
|
|||||||
.pipe(mocha({reporter: 'spec'}));
|
.pipe(mocha({reporter: 'spec'}));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('babel', ['clean'], function() {
|
gulp.task('babel', function() {
|
||||||
return gulp.src('lib/**/*.js')
|
return gulp.src('lib/**/*.js')
|
||||||
.pipe(babel())
|
.pipe(babel())
|
||||||
.pipe(gulp.dest('dist'));
|
.pipe(gulp.dest('dist'));
|
||||||
@ -46,5 +50,32 @@ gulp.task('watch', function() {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('prepublish', ['nsp', 'babel']);
|
gulp.task('webpack', ['webpack:standalone', 'webpack:standalone:min']);
|
||||||
|
|
||||||
|
gulp.task('webpack:standalone', function() {
|
||||||
|
var config = createWebpackConfig({ filename: 'updeep-standalone.js' });
|
||||||
|
|
||||||
|
return gulp.src('lib/index.js')
|
||||||
|
.pipe(webpack(config))
|
||||||
|
.pipe(gulp.dest('dist/umd/'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('webpack:standalone:min', function() {
|
||||||
|
var config = createWebpackConfig({
|
||||||
|
filename: 'updeep-standalone.min.js',
|
||||||
|
minify: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
return gulp.src('lib/index.js')
|
||||||
|
.pipe(webpack(config))
|
||||||
|
.pipe(gulp.dest('dist/umd/'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('build', ['babel', 'webpack']);
|
||||||
|
|
||||||
|
gulp.task('build:clean', ['clean'], function(done) {
|
||||||
|
gulp.start('build', done);
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('prepublish', ['nsp', 'build:clean']);
|
||||||
gulp.task('default', ['static', 'test']);
|
gulp.task('default', ['static', 'test']);
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-core": "^5.5.0",
|
"babel-core": "^5.5.0",
|
||||||
"babel-eslint": "^4.0.5",
|
"babel-eslint": "^4.0.5",
|
||||||
|
"babel-loader": "^5.3.2",
|
||||||
"chai": "^3.2.0",
|
"chai": "^3.2.0",
|
||||||
"eslint": "^0.24.1",
|
"eslint": "^0.24.1",
|
||||||
"eslint-config-airbnb": "0.0.7",
|
"eslint-config-airbnb": "0.0.7",
|
||||||
@ -44,6 +45,8 @@
|
|||||||
"gulp-nsp": "^0.4.5",
|
"gulp-nsp": "^0.4.5",
|
||||||
"gulp-watch": "^4.3.4",
|
"gulp-watch": "^4.3.4",
|
||||||
"lodash": "^3.0.0",
|
"lodash": "^3.0.0",
|
||||||
"rimraf": "^2.4.2"
|
"rimraf": "^2.4.2",
|
||||||
|
"webpack": "^1.10.5",
|
||||||
|
"webpack-stream": "^2.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
webpack.config.js
Normal file
3
webpack.config.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
'use strict'; /* eslint strict:0, no-var:0, func-names:0 */
|
||||||
|
|
||||||
|
module.exports = require('./createWebpackConfig')();
|
Loading…
Reference in New Issue
Block a user