set up build script scripts to build offline bundle

This commit is contained in:
Val Erastov 2016-12-19 03:52:01 -08:00
parent d4dc1dfef4
commit 7af5780d03
5 changed files with 40 additions and 5 deletions

32
gulpfile.js Normal file
View file

@ -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']);

View file

@ -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",

View file

@ -21,7 +21,7 @@
<script src="lib/csg.js"></script>
<script src="lib/formats.js"></script>
<script src="lib/pnltri.js"></script>
<script src="/static/index.bundle.js"></script>
<script src="static/index.bundle.js"></script>
</head>
<body>
<div class="app-tab-view" id="view-3d">

View file

@ -6,7 +6,7 @@
<link rel="shortcut icon" href="img/tgn.png" />
<link rel="stylesheet" href="css/toolkit.css">
<link rel="stylesheet" href="lib/font-awesome/css/font-awesome.min.css">
<script src="/static/sketcher.bundle.js"></script>
<script src="static/sketcher.bundle.js"></script>
</head>
<body>
<a id="downloader" style="display: none;" ></a>

View file

@ -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/'