Skip to content

Frontend Generator: I don't want webpack

Miguel Palau edited this page Aug 10, 2018 · 1 revision

Or the client doesn't want webpack...

Simple, go to gulp/common/scripts.js and tweak as follows:

const gulp = require('gulp')
const concat = require('gulp-concat')

gulp.task('vendor:scripts', () =>
  gulp.src([
	// You'll have to include your dependencies manually
	// here and restart the server too manual? Boring?
	// Well there's webpack for that but you don't want that, lol
    'node_modules/jquery/dist/jquery.js',
  ])
    .pipe(concat('vendors.js'))
    .pipe(gulp.dest('dist/assets/js'))
)

gulp.task('custom:scripts', () =>
  // things might not work as expected since files get included
  // in alphabetic order, so it's easier to name them:
  // 01-foo.js 02-bar.js 03-baz.js etc
  gulp.src('src/assets/js/**/*.js')
    .pipe(concat('custom.js'))
    .pipe(gulp.dest('dist/assets/js'))
)

gulp.task('scripts', gulp.series('vendor:scripts', 'custom:scripts'))

Don't forget to reference those files on your html files or if you're using pug on the primary layout.

Clone this wiki locally