mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-10 19:57:09 +03:00
4b06fe3958
* Introduce static asset build infrastructure * Enhance gulpfile.js * Introduce node service * BrowserSync debug-only support * Remove newline before BrowserSync debug-only support section * FIx node Dockerfile package.json COPY * Try fiixing node Dockerfile package.json COPY ones again * Switch to `node:7-slim` * Try switching to node:6 To account for possible node:7 docker-compose incompatibiltiy * Revert "Try switching to node:6" This reverts commit62cc02df1a
. * Try switcging workdir to /app * Try utilizing relative package.json path * Resetting to the last version working locally with docker-compose 1.11.x * Build upon the latest node:7.9-slim * Stop dockerignoring package.json * Fix typo * Try a different package.json path * Revert "Try a different package.json path" This reverts commitf29f8500b8
. * Revert "Fix typo" This reverts commit02033729b5
. * Revert "Stop dockerignoring package.json" This reverts commit63c5491546
. * Upgrade docker-engine and docker-compose used by Travis CI * Fix .travis.yml comments * Inline docker-engine and docker-compose versions * DEBUG: pwd * Revert "DEBUG: pwd " This reverts commit6c2ed4321a
. * Try copying package.json to the same dir as node Dockerfile's * Revert "Try copying package.json to the same dir as node Dockerfile's" This reverts commit24340a0783
. * Try out node:7.9 * Revert "Try out node:7.9" This reverts commit32286d33c2
. * Revert "Upgrade docker-engine and docker-compose used by Travis CI" * Get rid of npm-check-updates Reason: Reserved for the upcoming PR * Get rid of npm-check Reason: Reserved for the upcoming PR * Get rid of 'standard' npm package Reason: Reserved for the upcoming PR * Clean up package.json * Preserve package.json uncoditionally Since we now have *unconditional* node.js integration, `package.json` must be out there whenever `node` service gets built * Upgrade node service image to 7.10 * Document Node.js-Docker integration * Fix gulpfile.js images region name * Get rid of Gulp migrate task * Document Gulp-Docker integration * Introduce static asset build infrastructure * Enhance gulpfile.js * Introduce node service * BrowserSync debug-only support * Remove newline before BrowserSync debug-only support section * FIx node Dockerfile package.json COPY * Try fiixing node Dockerfile package.json COPY ones again * Switch to `node:7-slim` * Try switching to node:6 To account for possible node:7 docker-compose incompatibiltiy * Revert "Try switching to node:6" This reverts commit62cc02df1a
. * Try switcging workdir to /app * Try utilizing relative package.json path * Resetting to the last version working locally with docker-compose 1.11.x * Build upon the latest node:7.9-slim * Stop dockerignoring package.json * Revert "Stop dockerignoring package.json" This reverts commit63c5491546
. * Fix typo * Revert "Fix typo" This reverts commit02033729b5
. * Try a different package.json path * Revert "Try a different package.json path" This reverts commitf29f8500b8
. * Upgrade docker-engine and docker-compose used by Travis CI * Fix .travis.yml comments * Inline docker-engine and docker-compose versions * DEBUG: pwd * Revert "DEBUG: pwd " This reverts commit6c2ed4321a
. * Try copying package.json to the same dir as node Dockerfile's * Revert "Try copying package.json to the same dir as node Dockerfile's" This reverts commit24340a0783
. * Try out node:7.9 * Revert "Try out node:7.9" This reverts commit32286d33c2
. * Revert "Upgrade docker-engine and docker-compose used by Travis CI" * Get rid of npm-check-updates Reason: Reserved for the upcoming PR * Get rid of npm-check Reason: Reserved for the upcoming PR * Get rid of 'standard' npm package Reason: Reserved for the upcoming PR * Clean up package.json * Preserve package.json uncoditionally Since we now have *unconditional* node.js integration, `package.json` must be out there whenever `node` service gets built * Upgrade node service image to 7.10 * Document Node.js-Docker integration * Fix gulpfile.js images region name * Get rid of Gulp migrate task * Document Gulp-Docker integration * Remove Gulp-Docker integraton not supported initialization message
140 lines
4.1 KiB
JavaScript
140 lines
4.1 KiB
JavaScript
const gulp = require('gulp')
|
|
const pump = require('pump')
|
|
const sass = require('gulp-sass')
|
|
const pjson = require('./package.json')
|
|
const autoprefixer = require('gulp-autoprefixer')
|
|
const cleanCSS = require('gulp-clean-css')
|
|
const rename = require('gulp-rename')
|
|
const pixrem = require('gulp-pixrem')
|
|
const concat = require('gulp-concat')
|
|
const uglify = require('gulp-uglify')
|
|
const imagemin = require('gulp-imagemin')
|
|
const clean = require('gulp-clean')
|
|
const spawn = require('child_process').spawn
|
|
const runSequence = require('run-sequence')
|
|
const browserSync = require('browser-sync').create()
|
|
const pathsConfig = function (appName) {
|
|
this.paths = {}
|
|
|
|
this.paths['app'] = './' + (appName || pjson.name)
|
|
|
|
this.paths['static'] = this.paths['app'] + '/static'
|
|
|
|
this.paths['build'] = this.paths['static'] + '/build'
|
|
|
|
this.paths['buildImages'] = this.paths['build'] + '/images'
|
|
this.paths['images'] = this.paths['static'] + '/images'
|
|
this.paths['images_files'] = this.paths['images'] + '/*'
|
|
this.paths['buildImagesFavicons'] = this.paths['buildImages'] + '/favicons'
|
|
this.paths['imagesFavicons'] = this.paths['images'] + '/favicons'
|
|
this.paths['imagesFavicons_files'] = this.paths['imagesFavicons'] + '/*'
|
|
|
|
this.paths['build_scriptsFileName'] = 'scripts.js'
|
|
this.paths['scripts'] = this.paths['static'] + '/scripts'
|
|
this.paths['scripts_files'] = this.paths['scripts'] + '/**/*'
|
|
this.paths['scriptsJs'] = this.paths['scripts'] + '/js'
|
|
this.paths['scriptsJs_files'] = this.paths['scriptsJs'] + '/*.js'
|
|
|
|
this.paths['build_stylesFileName'] = 'styles.css'
|
|
this.paths['styles'] = this.paths['static'] + '/styles'
|
|
this.paths['styles_files'] = this.paths['styles'] + '/**/*'
|
|
this.paths['stylesSass'] = this.paths['styles'] + '/sass'
|
|
this.paths['stylesSass_files'] = this.paths['stylesSass'] + '/*.scss'
|
|
this.paths['stylesCss'] = this.paths['styles'] + '/css'
|
|
this.paths['stylesCss_files'] = this.paths['stylesCss'] + '/*.css'
|
|
|
|
this.paths['templates'] = this.paths['app'] + '/templates'
|
|
this.paths['templates_files'] = this.paths['templates'] + '/**/*.html'
|
|
|
|
return this.paths
|
|
}
|
|
const paths = pathsConfig()
|
|
|
|
// region images
|
|
gulp.task('favicons-images', function (cb) {
|
|
pump([gulp.src(paths.imagesFavicons_files),
|
|
gulp.dest(paths.buildImagesFavicons)],
|
|
cb)
|
|
})
|
|
|
|
gulp.task('nonfavicons-images', function (cb) {
|
|
pump([gulp.src(paths.images_files),
|
|
imagemin(),
|
|
gulp.dest(paths.buildImages)],
|
|
cb)
|
|
})
|
|
|
|
gulp.task('images', function () {
|
|
runSequence(['favicons-images', 'nonfavicons-images'])
|
|
})
|
|
// endregion
|
|
|
|
// region scripts
|
|
gulp.task('js-scripts', function (cb) {
|
|
pump([gulp.src(paths.scriptsJs_files),
|
|
concat(paths.build_scriptsFileName),
|
|
uglify(),
|
|
rename({suffix: '.min'}),
|
|
gulp.dest(paths.build)],
|
|
cb)
|
|
})
|
|
|
|
gulp.task('scripts', function () {
|
|
runSequence('js-scripts')
|
|
})
|
|
// endregion
|
|
|
|
// region styles
|
|
gulp.task('sass-styles', function (cb) {
|
|
pump([gulp.src(paths.stylesSass_files),
|
|
sass(),
|
|
gulp.dest(paths.stylesCss)],
|
|
cb
|
|
)
|
|
})
|
|
|
|
gulp.task('css-styles', function (cb) {
|
|
pump([gulp.src(paths.stylesCss_files),
|
|
concat(paths.build_stylesFileName),
|
|
autoprefixer({browsers: ['last 2 versions']}),
|
|
pixrem(),
|
|
cleanCSS({rebaseTo: '../../'}),
|
|
rename({suffix: '.min'}),
|
|
gulp.dest(paths.build)],
|
|
cb)
|
|
})
|
|
|
|
gulp.task('styles', function () {
|
|
runSequence('sass-styles', 'css-styles')
|
|
})
|
|
// endregion
|
|
|
|
// region build
|
|
gulp.task('build', function () {
|
|
runSequence(['images', 'scripts', 'styles'])
|
|
})
|
|
|
|
gulp.task('clean-build', function (cb) {
|
|
pump([gulp.src(paths.build),
|
|
clean()],
|
|
cb)
|
|
})
|
|
// endregion
|
|
|
|
gulp.task('init-browserSync', function () {
|
|
browserSync.init({
|
|
host: 'localhost:8000'
|
|
})
|
|
})
|
|
|
|
gulp.task('watch', function () {
|
|
gulp.watch(paths.images_files, ['images']).on('change', browserSync.reload)
|
|
gulp.watch(paths.scripts_files, ['scripts']).on('change', browserSync.reload)
|
|
gulp.watch(paths.styles_files, ['styles']).on('change', browserSync.reload)
|
|
gulp.watch(paths.templates_files).on('change', browserSync.reload)
|
|
})
|
|
|
|
gulp.task('default', function () {
|
|
runSequence('build', 'init-browserSync', 'watch')
|
|
})
|