diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..2bfe5fb5 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,32 @@ +const gulp = require('gulp'); +const webpack = require('webpack'); +const webpackConfig = require('./webpack.config'); +const del = require('del'); + +gulp.task('clean', function () { + del('dist') +}); + +gulp.task('build', function () { + webpack(webpackConfig, function (error) { + if (error) { + console.log('webpack failed'); + console.log(error); + } + }); +}); + +gulp.task('resources', function () { + const res = []; + excluding('web/app', res); + excluding('web/test', res); + res.push('web/**/*'); + gulp.src(res).pipe(gulp.dest('dist')); +}); + +function excluding(path, filter) { + filter.push('!' + path + '/**/*', '!' + path); +} + + +gulp.task('default', ['clean', 'build', 'resources']); diff --git a/package.json b/package.json index ca55a8e9..721a6ff8 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "JS.Sketcher is a parametric 2D and 3D CAD modeler written in pure javascript", "scripts": { "start": "webpack-dev-server --content-base web/ --port 3000", - "build": "webpack --config webpack.config.js --progress --profile --colors", + "pack": "webpack --config webpack.config.js --progress --profile --colors", + "build": "gulp", "lint": "eslint web/app -c ./build/.eslintrc.json --ignore-path ./build/.eslintignore" }, "repository": { @@ -35,7 +36,9 @@ "eslint-plugin-import": "1.12.0", "style-loader": "0.13.1", "webpack": "1.13.2", - "webpack-dev-server": "1.15.0" + "webpack-dev-server": "1.15.0", + "gulp": "3.9.1", + "del": "2.2.2" }, "dependencies": { "sprintf": "0.1.5", diff --git a/web/index.html b/web/index.html index 33e94251..4635c127 100644 --- a/web/index.html +++ b/web/index.html @@ -21,7 +21,7 @@ - +
diff --git a/web/sketcher.html b/web/sketcher.html index b0e6e99a..f0a0452c 100644 --- a/web/sketcher.html +++ b/web/sketcher.html @@ -6,7 +6,7 @@ - + diff --git a/webpack.config.js b/webpack.config.js index 58a9ac69..11a26911 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,7 +8,7 @@ module.exports = { sketcher: ['./web/app/sketcher'] }, output: { - path: path.join(__dirname, 'dist'), + path: path.join(__dirname, 'dist/static'), filename: '[name].bundle.js', chunkFilename: '[id].bundle.js', publicPath: '/static/'