diff --git a/{{cookiecutter.project_slug}}/compose.yml b/{{cookiecutter.project_slug}}/compose.yml index 65f797f..79741f6 100644 --- a/{{cookiecutter.project_slug}}/compose.yml +++ b/{{cookiecutter.project_slug}}/compose.yml @@ -14,6 +14,7 @@ services: - ui volumes: - '.:/app:z' + - /app/node_modules command: npm run dev ports: - '3000:3000' @@ -98,6 +99,7 @@ services: redis: image: redis:6 container_name: '{{ cookiecutter.project_slug }}_redis' + command: /bin/sh -c "redis-server --requirepass $$REDIS_PASSWORD" volumes: - '{{ cookiecutter.project_slug }}_redis_data:/data' env_file: diff --git a/{{cookiecutter.project_slug}}/gulpfile.js b/{{cookiecutter.project_slug}}/gulpfile.js index ab2f868..31fe609 100644 --- a/{{cookiecutter.project_slug}}/gulpfile.js +++ b/{{cookiecutter.project_slug}}/gulpfile.js @@ -23,22 +23,22 @@ const uglify = require('gulp-uglify-es').default; // Relative paths function function pathsConfig(appName) { - this.app = `./${pjson.name}`; - const vendorsRoot = 'node_modules'; - - return { - vendorsJs: [ - `${vendorsRoot}/@popperjs/core/dist/umd/popper.js`, - `${vendorsRoot}/bootstrap/dist/js/bootstrap.js`, - ], - app: this.app, - templates: `${this.app}/templates`, - css: `${this.app}/static/css`, - sass: `${this.app}/static/sass`, - fonts: `${this.app}/static/fonts`, - images: `${this.app}/static/images`, - js: `${this.app}/static/js`, - }; + this.app = './app'; + const vendorsRoot = 'node_modules'; + + return { + vendorsJs: [ + `${vendorsRoot}/@popperjs/core/dist/umd/popper.js`, + `${vendorsRoot}/bootstrap/dist/js/bootstrap.js`, + ], + app: this.app, + templates: `${this.app}/templates`, + css: `${this.app}/static/css`, + sass: `${this.app}/static/sass`, + fonts: `${this.app}/static/fonts`, + images: `${this.app}/static/images`, + js: `${this.app}/static/js`, + }; } const paths = pathsConfig(); @@ -49,91 +49,91 @@ const paths = pathsConfig(); // Styles autoprefixing and minification const processCss = [ - autoprefixer(), // adds vendor prefixes - pixrem(), // add fallbacks for rem units + autoprefixer(), // adds vendor prefixes + pixrem(), // add fallbacks for rem units ]; const minifyCss = [ - cssnano({ preset: 'default' }), // minify result + cssnano({ preset: 'default' }), // minify result ]; function project_styles() { - return src(`${paths.sass}/project.scss`) - .pipe( - sass({ - importer: tildeImporter, - includePaths: [paths.sass], - }).on('error', sass.logError), - ) - .pipe(plumber()) // Checks for errors - .pipe(postcss(processCss)) - .pipe(dest(paths.css)) - .pipe(rename({ suffix: '.min' })) - .pipe(postcss(minifyCss)) // Minifies the result - .pipe(dest(paths.css)); + return src(`${paths.sass}/project.scss`) + .pipe( + sass({ + importer: tildeImporter, + includePaths: [paths.sass], + }).on('error', sass.logError), + ) + .pipe(plumber()) // Checks for errors + .pipe(postcss(processCss)) + .pipe(dest(paths.css)) + .pipe(rename({ suffix: '.min' })) + .pipe(postcss(minifyCss)) // Minifies the result + .pipe(dest(paths.css)); } // Javascript minification function scripts() { - return src([`${paths.js}/project.js`, `${paths.js}/*-page.js`]) - .pipe(plumber()) // Checks for errors - .pipe(uglify()) // Minifies the js - .pipe(rename({ suffix: '.min' })) - .pipe(dest(paths.js)); + return src([`${paths.js}/project.js`, `${paths.js}/*-page.js`]) + .pipe(plumber()) // Checks for errors + .pipe(uglify()) // Minifies the js + .pipe(rename({ suffix: '.min' })) + .pipe(dest(paths.js)); } // Vendor Javascript minification function vendorScripts() { - return src(paths.vendorsJs, { sourcemaps: true }) - .pipe(concat('vendors.js')) - .pipe(dest(paths.js)) - .pipe(plumber()) // Checks for errors - .pipe(uglify()) // Minifies the js - .pipe(rename({ suffix: '.min' })) - .pipe(dest(paths.js, { sourcemaps: '.' })); + return src(paths.vendorsJs, { sourcemaps: true }) + .pipe(concat('vendors.js')) + .pipe(dest(paths.js)) + .pipe(plumber()) // Checks for errors + .pipe(uglify()) // Minifies the js + .pipe(rename({ suffix: '.min' })) + .pipe(dest(paths.js, { sourcemaps: '.' })); } // Run django server function runServer(cb) { - const cmd = spawn('python', ['manage.py', 'runserver'], { stdio: 'inherit' }); - cmd.on('close', function (code) { - console.log('runServer exited with code ' + code); - cb(code); - }); + const cmd = spawn('python', ['manage.py', 'runserver'], { stdio: 'inherit' }); + cmd.on('close', function (code) { + console.log('runServer exited with code ' + code); + cb(code); + }); } // Browser sync server for live reload function initBrowserSync() { - browserSync.init( - [`${paths.css}/*.css`, `${paths.js}/*.js`, `${paths.templates}/*.html`], - { - // https://www.browsersync.io/docs/options/#option-open - // Disable as it doesn't work from inside a container - open: false, - // https://www.browsersync.io/docs/options/#option-proxy - proxy: { - target: 'ui:8000', - proxyReq: [ - function (proxyReq, req) { - // Assign proxy 'host' header same as current request at Browsersync server - proxyReq.setHeader('Host', req.headers.host); - }, - ], - }, - // https://browsersync.io/docs/options/#option-notify - notify: false, - }, - ); + browserSync.init( + [`${paths.css}/*.css`, `${paths.js}/*.js`, `${paths.templates}/*.html`], + { + // https://www.browsersync.io/docs/options/#option-open + // Disable as it doesn't work from inside a container + open: false, + // https://www.browsersync.io/docs/options/#option-proxy + proxy: { + target: 'ui:8000', + proxyReq: [ + function (proxyReq, req) { + // Assign proxy 'host' header same as current request at Browsersync server + proxyReq.setHeader('Host', req.headers.host); + }, + ], + }, + // https://browsersync.io/docs/options/#option-notify + notify: false, + }, + ); } // Watch function watchPaths() { - watch(`${paths.sass}/*.scss`, project_styles); - watch(`${paths.templates}/**/*.html`).on('change', reload); - watch([`${paths.js}/*.js`, `!${paths.js}/*.min.js`], scripts).on( - 'change', - reload, - ); + watch(`${paths.sass}/*.scss`, project_styles); + watch(`${paths.templates}/**/*.html`).on('change', reload); + watch([`${paths.js}/*.js`, `!${paths.js}/*.min.js`], scripts).on( + 'change', + reload, + ); } // Generate all assets