Improve build

This commit is contained in:
Boris Kubiak 2018-01-10 23:56:46 +01:00
parent 65aeebc75e
commit 7da5778124
4 changed files with 3353 additions and 481 deletions

View file

@ -8,6 +8,8 @@ const source = require('vinyl-source-stream');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const cleanCSS = require('gulp-clean-css');
const rename = require("gulp-rename");
const replace = require('gulp-replace');
// Browserify
gulp.task('browserify', cb => {
@ -30,10 +32,11 @@ gulp.task('sass', cb => {
// Build javascript
gulp.task('build-js', ['browserify'], cb => {
pump([
gulp.src('js/bundle.js'),
gulp.src(['js/index.js', 'js/bundle.js']),
babel({presets: ['env'], plugins: ['@babel/plugin-transform-object-assign']}),
uglify(),
gulp.dest('js')
rename({extname: ".min.js"}),
gulp.dest('build/js')
], cb);
});
@ -47,12 +50,24 @@ gulp.task('build-css', ['sass'], cb => {
cascade: false
}),
cleanCSS({compatibility: 'ie8'}),
gulp.dest('css')
rename({extname: ".min.css"}),
gulp.dest('build/css')
], cb);
});
gulp.task('replace-path', cb =>{
pump([
gulp.src('index.html'),
replace('src="js/', 'src="build/js/'),
replace('.js', '.min.js'),
replace('href="css/', 'href="build/css/'),
replace('.css', '.min.css'),
gulp.dest('./')
], cb);
});
// Build app
gulp.task('default', ['build-js', 'build-css']);
gulp.task('build', ['build-js', 'build-css', 'replace-path']);
// Watch changes and compile on the fly
gulp.task('watch', () => {

View file

@ -129,7 +129,7 @@
</div>
<!--JS-->
<script src="https://unpkg.com/vue/dist/vue.min.js"></script>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="js/index.js" type="text/javascript"></script>
</body>
</html>

3803
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -11,17 +11,19 @@
"gulp-autoprefixer": "^4.0.0",
"gulp-babel": "^7.0.0",
"gulp-clean-css": "^3.9.0",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.6.1",
"gulp-sass": "^3.1.0",
"gulp-uglify": "^3.0.0",
"pump": "^2.0.0",
"randombytes": "^2.0.5",
"randombytes": "^2.0.6",
"vinyl-source-stream": "^1.1.0",
"xo": "^0.18.2"
},
"license": "ISC",
"main": "index.js",
"scripts": {
"build": "node ./node_modules/gulp/bin/gulp.js",
"build": "node ./node_modules/gulp/bin/gulp.js build",
"test": "node ./node_modules/xo/cli.js",
"watch": "node ./node_modules/gulp/bin/gulp.js watch"
},