forum-django/gulpfile.js
László Károlyi f3598f67d9
All checks were successful
buildbot/Hondaforum Site Build done.
Fix firefox android not sending PointerEvents
2023-10-07 16:13:05 +02:00

95 lines
3.6 KiB
JavaScript

import { deleteAsync } from 'del'
import GulpClient from 'gulp'
import logger from 'fancy-log'
import PluginError from 'plugin-error'
import webpackStream from 'webpack-stream'
import webpack from 'webpack'
import Server from 'webpack-dev-server'
import path from 'path'
import gulpEslint from 'gulp-eslint-new'
import { fileURLToPath } from 'url'
const sourceGlob = ['frontend/src/ts/**/*.js']
const _myFileName = fileURLToPath(import.meta.url)
const _myDirName = path.dirname(_myFileName)
// const htmlReplaceSkeleton = () =>
// GulpClient.src('frontend/src/index.html')
// .pipe(htmlreplace({
// loader: {
// src: null,
// tpl: bundleHelper.createHeader(),
// },
// }))
// .pipe(GulpClient.dest('frontend/dist/'))
// Cleanup task
GulpClient.task('clean', () => deleteAsync(['./frontend/dist/**/*']))
// Lint Task
if (process.argv.length < 4) {
GulpClient.task('lint', () => GulpClient.src(sourceGlob)
// gulpEslint() attaches the lint output to the "gulpEslint" property
// of the file object so it can be used by other modules.
.pipe(gulpEslint())
// gulpEslint.format() outputs the lint results to the console.
// Alternatively use gulpEslint.formatEach() (see Docs).
.pipe(gulpEslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failAfterError last.
.pipe(gulpEslint.failAfterError()))
} else if (process.argv[3] === '-n') {
const passedFiles = process.argv[4].split('\n')
GulpClient.task('lint', () => GulpClient.src(passedFiles)
// gulpEslint() attaches the lint output to the "gulpEslint" property
// of the file object so it can be used by other modules.
.pipe(gulpEslint())
// gulpEslint.format() outputs the lint results to the console.
// Alternatively use gulpEslint.formatEach() (see Docs).
.pipe(gulpEslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failAfterError last.
.pipe(gulpEslint.failAfterError()))
}
GulpClient.task('clean-lint', GulpClient.parallel(['clean', 'lint']))
GulpClient.task('webpack-prod', GulpClient.series('clean-lint', async (done) => {
const prodConfig = (await import('./frontend/webpack/config.prod.js')).default
GulpClient.src(sourceGlob)
.pipe(webpackStream(prodConfig, webpack))
.on('error', (error) => { done(error) })
.pipe(GulpClient.dest('frontend/dist/assets/'))
.on('end', done)
}))
GulpClient.task('webpack-dev', GulpClient.series(['clean-lint'], async (done) => {
const devConfig = (await import('./frontend/webpack/config.dev.js')).default
GulpClient.src(sourceGlob)
.pipe(webpackStream(devConfig, webpack))
.on('error', (error) => { done(error) })
.pipe(GulpClient.dest('frontend/dist/assets/'))
.on('end', done)
}))
GulpClient.task('build', GulpClient.series(['webpack-prod']))
GulpClient.task('build-dev', GulpClient.series(['clean', 'webpack-dev']))
GulpClient.task('webpack-dev-server', GulpClient.series(['clean'], async (done) => {
const config = (
await import('./frontend/webpack/config.dev-server.js')).default
const compiler = webpack(config, () => {})
const devServerOptions = config.devServer
const server = new Server(devServerOptions, compiler)
// @See https://webpack.js.org/configuration/dev-server/#usage-via-api
server.startCallback((err) => {
if (err) throw new PluginError('webpack-dev-server', err)
// Server listening
logger('[webpack-dev-server]', `http://${devServerOptions.host}:3000/`)
})
done()
}))
GulpClient.task('default', GulpClient.series('clean-lint'))