Skip to content

Commit

Permalink
use webpack to build dist to solve #131 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Nov 13, 2015
1 parent 0f5fc67 commit fa8ab97
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 13 deletions.
37 changes: 24 additions & 13 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var source = require("vinyl-source-stream");
var babel = require('gulp-babel');
var concatCss = require('gulp-concat-css');
var cssmin = require('gulp-cssmin');
var webpack = require('webpack');

var watching = false;
var demo = false;
Expand All @@ -13,17 +14,17 @@ var demo = false;
gulp.task("default", ["prod"]);

gulp.task("prod", function () {
gulp.src('./src/**/*.js')
.pipe(babel())
.pipe(gulp.dest('./lib'));
gulp.src('./css/react-bootstrap-table.css')
.pipe(concatCss("./react-bootstrap-table.min.css"))
.pipe(cssmin())
.pipe(gulp.dest('./css'));
gulp.src('./css/react-bootstrap-table-all.css')
.pipe(concatCss("./react-bootstrap-table-all.min.css"))
.pipe(cssmin())
.pipe(gulp.dest('./css'));
// gulp.src('./src/**/*.js')
// .pipe(babel())
// .pipe(gulp.dest('./lib'));
// gulp.src('./css/react-bootstrap-table.css')
// .pipe(concatCss("./react-bootstrap-table.min.css"))
// .pipe(cssmin())
// .pipe(gulp.dest('./css'));
// gulp.src('./css/react-bootstrap-table-all.css')
// .pipe(concatCss("./react-bootstrap-table-all.min.css"))
// .pipe(cssmin())
// .pipe(gulp.dest('./css'));
buildProdDist();
});

Expand All @@ -39,8 +40,18 @@ function buildDemoCode() {
}

function buildProdDist() {
demo = false;
browserifing("./src/index.js", "react-bootstrap-table.min.js", "./dist");
// Give up the browserify to build product, cause of #131, change to webpack instead
// demo = false;
// browserifing("./src/index.js", "react-bootstrap-table.min.js", "./dist");
var config = require("./webpack.production.config");
var compiler = webpack(config);

compiler.run(function(err, stats) {
if(null != err)
console.error(err);
else
console.log("building success");
});
}

function browserifing(main, bundleName, dest) {
Expand Down
41 changes: 41 additions & 0 deletions webpack.production.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
var webpack = require('webpack');

module.exports = {

entry: {
'react-bootstrap-table': './src/index.js'
},
output: {
path: './dist',
filename: '[name].min.js',
libraryTarget: 'umd'
},
externals: [
{
'react': {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
}
},
{
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom'
}
}
],
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['babel']
}]
},

plugins: [
]
};

0 comments on commit fa8ab97

Please sign in to comment.