Skip to content

Commit

Permalink
feat(dev): update build process
Browse files Browse the repository at this point in the history
change output from `resources/static/` to `static/`
  • Loading branch information
runjuu committed Nov 2, 2020
1 parent 90e6a28 commit df1043b
Show file tree
Hide file tree
Showing 11 changed files with 291 additions and 283 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,5 @@ static/
.DS_Store
report.html
strings.csv
/resources/static/css/tailwind.min.css
resources/static/style.css

.calva
67 changes: 45 additions & 22 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,58 @@
const path = require('path')
const gulp = require('gulp')
const postcss = require('gulp-postcss')
const concat = require('gulp-concat')
const merge = require('merge-stream')
const cleanCSS = require('gulp-clean-css')
const del = require('del')

const outputPath = path.join(__dirname, 'static')
const resourcesPath = path.join(__dirname, 'resources')
const sourcePath = path.join(__dirname, 'src')
const resourceFilePath = path.join(resourcesPath, '**')

const tailwind = {
entryPath: './tailwind.css',
cssPath: './src/**/*.css',
outputDir: './resources/static/css/',
outputName: 'tailwind.min.css',
paths: [path.join(__dirname, 'tailwind.css'), path.join(sourcePath, '**/*.css')],
outputDir: path.join(outputPath, 'css'),
outputName: 'tailwind.build.css',
}

function buildCSS() {
return merge(gulp.src(tailwind.entryPath), gulp.src(tailwind.cssPath))
.pipe(postcss())
.pipe(concat(tailwind.outputName))
.pipe(gulp.dest(tailwind.outputDir))
}
const css = {
watchCSS() {
return gulp.watch(tailwind.paths, { ignoreInitial: false }, css._buildTailwind)
},

function watchCSS() {
return gulp.watch([tailwind.entryPath, tailwind.cssPath], { ignoreInitial: false }, buildCSS)
}
buildCSS(...params) {
return gulp.series(css._buildTailwind, css._optimizeCSSForRelease)(...params)
},

_buildTailwind() {
return gulp.src(tailwind.paths)
.pipe(postcss())
.pipe(concat(tailwind.outputName))
.pipe(gulp.dest(tailwind.outputDir))
},

function optimizeCSSForRelease() {
return gulp.src('./resources/static/css/style.css')
.pipe(cleanCSS())
.pipe(gulp.dest('./resources/static/'))
_optimizeCSSForRelease() {
return gulp.src(path.join(outputPath, 'css', 'style.css'))
.pipe(cleanCSS())
.pipe(gulp.dest(outputPath))
},
}

const releaseCSS = gulp.series(buildCSS, optimizeCSSForRelease)
const common = {
clean() {
return del(outputPath)
},

syncResourceFile() {
return gulp.src(resourceFilePath).pipe(gulp.dest(outputPath))
},

keepSyncResourceFile() {
return gulp.watch(resourceFilePath, { ignoreInitial: false }, common.syncResourceFile)
}
}

exports.watchCSS = watchCSS
exports.buildCSS = buildCSS
exports.releaseCSS = releaseCSS
exports.clean = common.clean
exports.watch = gulp.parallel(common.keepSyncResourceFile, css.watchCSS)
exports.build = gulp.series(common.syncResourceFile, css.buildCSS)
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
"@fullhuman/postcss-purgecss": "^2.1.2",
"@tailwindcss/ui": "^0.1.3",
"cssnano": "^4.1.10",
"del": "^6.0.0",
"gulp": "^4.0.2",
"gulp-clean-css": "^4.3.0",
"gulp-concat": "^2.6.1",
"gulp-postcss": "^9.0.0",
"merge-stream": "^2.0.0",
"postcss": "^7.0.21",
"postcss-cli": "^6.1.3",
"purgecss": "^2.1.0",
"shadow-cljs": "2.8.81",
"tailwindcss": "^1.3.4"
},
"scripts": {
"watch:css": "gulp watchCSS",
"release:css": "NODE_ENV=production gulp releaseCSS",
"gulp:watch": "gulp watch",
"gulp:build": "NODE_ENV=production gulp build",
"watch": "clojure -A:cljs watch app publishing",
"release": "clojure -A:cljs release app publishing",
"watch-app": "clojure -A:cljs watch app",
"release-app": "clojure -A:cljs release app",
"debug": "clojure -A:cljs release app --debug",
"report": "clojure -A:cljs run shadow.cljs.build-report app report.html",
"clean": "/usr/bin/rm -rf target; /usr/bin/rm -rf ./resources/static/js/compiled; /usr/bin/rm -rf ./resources/static/js/cljs-runtime; /usr/bin/rm -rf ./resources/static/js/publishing; /usr/bin/rm -rf ./resources/static/js/main.js;"
"clean": "/usr/bin/rm -rf target; /usr/bin/rm -rf ./static;"
},
"dependencies": {
"codemirror": "^5.58.1",
Expand Down
2 changes: 1 addition & 1 deletion postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = (ctx) => ({
ctx.env === "production"
? require("@fullhuman/postcss-purgecss")({
content: [
'../resources/static/js/main.js',
'./static/js/main.js',
// etc.
],

Expand Down
6 changes: 3 additions & 3 deletions resources/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -875,13 +875,13 @@ iframe {
.aspect-ratio-square {
padding-top: 100%;
}
.aspect-ratio-16/9 {
.aspect-ratio-16\/9 {
padding-top: 56.25%;
}
.aspect-ratio-4/3 {
.aspect-ratio-4\/3 {
padding-top: 75%;
}
.aspect-ratio-21/9 {
.aspect-ratio-21\/9 {
padding-top: 42.86%;
}

Expand Down
1 change: 1 addition & 0 deletions resources/css/datepicker.css
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,4 @@
}
/*----------------------------------------------------------------------------------------
END OF DATE PICKER SECTION...
----------------------------------------------------------------------------------------*/
78 changes: 39 additions & 39 deletions resources/css/inter.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,152 +3,152 @@
font-style: normal;
font-weight: 100;
font-display: swap;
src: url("Inter-Thin-BETA.woff2") format("woff2"),
url("Inter-Thin-BETA.woff") format("woff");
src: url("/static/fonts/inter/Inter-Thin.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-Thin.woff?v=3.15") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 100;
font-display: swap;
src: url("Inter-ThinItalic-BETA.woff2") format("woff2"),
url("Inter-ThinItalic-BETA.woff") format("woff");
src: url("/static/fonts/inter/Inter-ThinItalic.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-ThinItalic.woff?v=3.15") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 200;
font-display: swap;
src: url("Inter-ExtraLight-BETA.woff2") format("woff2"),
url("Inter-ExtraLight-BETA.woff") format("woff");
src: url("/static/fonts/inter/Inter-ExtraLight.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-ExtraLight.woff?v=3.15") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 200;
font-display: swap;
src: url("Inter-ExtraLightItalic-BETA.woff2") format("woff2"),
url("Inter-ExtraLightItalic-BETA.woff") format("woff");
src: url("/static/fonts/inter/Inter-ExtraLightItalic.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-ExtraLightItalic.woff?v=3.15") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 300;
font-display: swap;
src: url("Inter-Light-BETA.woff2") format("woff2"),
url("Inter-Light-BETA.woff") format("woff");
src: url("/static/fonts/inter/Inter-Light.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-Light.woff?v=3.15") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 300;
font-display: swap;
src: url("Inter-LightItalic-BETA.woff2") format("woff2"),
url("Inter-LightItalic-BETA.woff") format("woff");
src: url("/static/fonts/inter/Inter-LightItalic.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-LightItalic.woff?v=3.15") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url("Inter-Regular.woff2") format("woff2"),
url("Inter-Regular.woff") format("woff");
src: url("/static/fonts/inter/Inter-Regular.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-Regular.woff?v=3.15") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 400;
font-display: swap;
src: url("Inter-Italic.woff2") format("woff2"),
url("Inter-Italic.woff") format("woff");
src: url("/static/fonts/inter/Inter-Italic.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-Italic.woff?v=3.15") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 500;
font-display: swap;
src: url("Inter-Medium.woff2") format("woff2"),
url("Inter-Medium.woff") format("woff");
src: url("/static/fonts/inter/Inter-Medium.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-Medium.woff?v=3.15") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 500;
font-display: swap;
src: url("Inter-MediumItalic.woff2") format("woff2"),
url("Inter-MediumItalic.woff") format("woff");
src: url("/static/fonts/inter/Inter-MediumItalic.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-MediumItalic.woff?v=3.15") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 600;
font-display: swap;
src: url("Inter-SemiBold.woff2") format("woff2"),
url("Inter-SemiBold.woff") format("woff");
src: url("/static/fonts/inter/Inter-SemiBold.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-SemiBold.woff?v=3.15") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 600;
font-display: swap;
src: url("Inter-SemiBoldItalic.woff2") format("woff2"),
url("Inter-SemiBoldItalic.woff") format("woff");
src: url("/static/fonts/inter/Inter-SemiBoldItalic.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-SemiBoldItalic.woff?v=3.15") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url("Inter-Bold.woff2") format("woff2"),
url("Inter-Bold.woff") format("woff");
src: url("/static/fonts/inter/Inter-Bold.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-Bold.woff?v=3.15") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 700;
font-display: swap;
src: url("Inter-BoldItalic.woff2") format("woff2"),
url("Inter-BoldItalic.woff") format("woff");
src: url("/static/fonts/inter/Inter-BoldItalic.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-BoldItalic.woff?v=3.15") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 800;
font-display: swap;
src: url("Inter-ExtraBold.woff2") format("woff2"),
url("Inter-ExtraBold.woff") format("woff");
src: url("/static/fonts/inter/Inter-ExtraBold.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-ExtraBold.woff?v=3.15") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 800;
font-display: swap;
src: url("Inter-ExtraBoldItalic.woff2") format("woff2"),
url("Inter-ExtraBoldItalic.woff") format("woff");
src: url("/static/fonts/inter/Inter-ExtraBoldItalic.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-ExtraBoldItalic.woff?v=3.15") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 900;
font-display: swap;
src: url("Inter-Black.woff2") format("woff2"),
url("Inter-Black.woff") format("woff");
src: url("/static/fonts/inter/Inter-Black.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-Black.woff?v=3.15") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 900;
font-display: swap;
src: url("Inter-BlackItalic.woff2") format("woff2"),
url("Inter-BlackItalic.woff") format("woff");
src: url("/static/fonts/inter/Inter-BlackItalic.woff2?v=3.15") format("woff2"),
url("/static/fonts/inter/Inter-BlackItalic.woff?v=3.15") format("woff");
}

/* -------------------------------------------------------
Expand All @@ -166,15 +166,15 @@ Usage:
font-display: swap;
font-style: normal;
font-named-instance: 'Regular';
src: url("Inter-upright.var.woff2") format("woff2");
src: url("/static/fonts/inter/Inter-roman.var.woff2?v=3.15") format("woff2");
}
@font-face {
font-family: 'Inter var';
font-weight: 100 900;
font-display: swap;
font-style: italic;
font-named-instance: 'Italic';
src: url("Inter-italic.var.woff2") format("woff2");
src: url("/static/fonts/inter/Inter-italic.var.woff2?v=3.15") format("woff2");
}


Expand All @@ -196,5 +196,5 @@ explicitly, e.g.
font-weight: 100 900;
font-display: swap;
font-style: oblique 0deg 10deg;
src: url("Inter.var.woff2") format("woff2");
src: url("/static/fonts/inter/Inter.var.woff2?v=3.15") format("woff2");
}
4 changes: 2 additions & 2 deletions resources/css/style.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@charset "utf-8";
@import "../fonts/inter/inter.css";
@import "./inter.css";
@import "./reveal.min.css";
@import "./reveal_black.min.css";
@import "./katex.min.css";
@import "./tailwind.min.css";
@import "./tailwind.build.css"; /* Build by gulp. Check `_buildTailwind` for more detail */
@import "./common.css";
@import "./datepicker.css";
@import "./highlight.css";
Expand Down
Loading

0 comments on commit df1043b

Please sign in to comment.