-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import { | ||
src, dest, series, parallel, | ||
} from 'gulp'; | ||
import concat from 'gulp-concat'; | ||
import ejs from 'gulp-ejs'; | ||
import rename from 'gulp-rename'; | ||
import htmlmin from 'gulp-htmlmin'; | ||
import { deleteAsync } from 'del'; | ||
import webpack from 'webpack-stream'; | ||
import TerserPlugin from 'terser-webpack-plugin'; | ||
import { readFile } from 'fs/promises'; | ||
|
||
const clean = () => deleteAsync(['./docs']); | ||
|
||
const BUILD_PATH = './docs/resources'; | ||
|
||
const webpackOptions = { | ||
mode: 'production', | ||
output: { filename: 'ws.min.js' }, | ||
optimization: { | ||
minimize: true, | ||
minimizer: [new TerserPlugin({ extractComments: false })], | ||
}, | ||
}; | ||
|
||
const buildJs = () => src(['server/scripts/index.mjs']) | ||
.pipe(webpack(webpackOptions)) | ||
.pipe(dest(BUILD_PATH)); | ||
|
||
const copyCss = () => src(['server/styles/main.css']) | ||
.pipe(concat('ws.min.css')) | ||
.pipe(dest(BUILD_PATH)); | ||
|
||
const compressHtml = async () => { | ||
const packageJson = await readFile('package.json'); | ||
const { version } = JSON.parse(packageJson); | ||
|
||
return src('views/*.ejs') | ||
.pipe(ejs({ | ||
production: true, | ||
version, | ||
}, {}, { ext: '.html' })) // Prevents EJS from escaping values | ||
.pipe(rename({ extname: '.html' })) | ||
.pipe(htmlmin({ collapseWhitespace: true })) | ||
.pipe(dest('./docs')); | ||
}; | ||
|
||
const copyOtherFiles = () => src(['server/robots.txt', 'server/manifest.json'], { base: 'server/' }) | ||
.pipe(dest('./docs')); | ||
|
||
const build = series(clean, parallel(buildJs, copyCss, compressHtml, copyOtherFiles)); | ||
|
||
export default build; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import updateVendor from './gulp/update-vendor.mjs'; | ||
import publishFrontend from './gulp/publish-frontend.mjs'; | ||
import publishFrontend from './gulp/build-gh-pages.mjs'; | ||
|
||
export { | ||
updateVendor, | ||
publishFrontend, | ||
}; | ||
|
||
export default publishFrontend; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters