refactor: group asset-related files

Fixes #15
This commit is contained in:
Oliver Davies 2022-07-22 21:39:49 +01:00
parent 36d55283d2
commit 3e8421d8b7
11 changed files with 55 additions and 54 deletions

View file

@ -4,25 +4,26 @@ ARG NODE_ENV="production"
ARG SCULPIN_ENV="prod"
ENV NODE_ENV="${NODE_ENV}" \
PATH="${PATH}:/node_modules/.bin" \
SCULPIN_ENV="${SCULPIN_ENV}"
SCULPIN_ENV="${SCULPIN_ENV}" \
USER="node"
RUN apk add --no-cache bash
WORKDIR /app
WORKDIR /app/assets
RUN mkdir -p /node_modules \
&& chown node:node -R /app /node_modules
USER node
COPY --chown=node:node *yarn* package.json ./
COPY --chown=node:node assets/*yarn* assets/package.json ./
RUN yarn install && yarn cache clean
COPY --chown=node:node . .
COPY --chown=node:node . ..
RUN if [ "${NODE_ENV}" != "development" ]; then \
./run yarn:build:css && ./run yarn:build:js; \
../run yarn:build:css && ../run yarn:build:js; \
else mkdir -p /app/build; fi
CMD ["bash"]

View file

@ -0,0 +1,29 @@
const esbuild = require("esbuild");
let minify = false;
let sourcemap = true;
let watch_fs = true;
if (process.env.NODE_ENV === "production") {
minify = true;
sourcemap = false;
watch_fs = false;
}
const watch = watch_fs && {
onRebuild(error) {
if (error) console.error("[watch] build failed", error);
else console.log("[watch] build finished");
},
};
console.log(watch);
esbuild.build({
entryPoints: ["./js/app.js"],
outfile: "../source/build/app.js",
bundle: true,
minify: minify,
sourcemap: sourcemap,
watch: watch,
plugins: [],
});

View file

@ -1,20 +1,19 @@
import 'alpinejs'
import 'focus-visible'
import bash from 'highlight.js/lib/languages/bash'
import hljs from 'highlight.js/lib/core'
import ini from 'highlight.js/lib/languages/ini'
import javascript from 'highlight.js/lib/languages/javascript'
import php from 'highlight.js/lib/languages/php'
import yaml from 'highlight.js/lib/languages/yaml'
import "focus-visible";
import bash from "highlight.js/lib/languages/bash";
import hljs from "highlight.js/lib/core";
import ini from "highlight.js/lib/languages/ini";
import javascript from "highlight.js/lib/languages/javascript";
import php from "highlight.js/lib/languages/php";
import yaml from "highlight.js/lib/languages/yaml";
hljs.registerLanguage('bash', bash);
hljs.registerLanguage('ini', ini);
hljs.registerLanguage('javascript', javascript);
hljs.registerLanguage('php', php);
hljs.registerLanguage('yaml', yaml);
hljs.registerLanguage("bash", bash);
hljs.registerLanguage("ini", ini);
hljs.registerLanguage("javascript", javascript);
hljs.registerLanguage("php", php);
hljs.registerLanguage("yaml", yaml);
document.addEventListener('DOMContentLoaded', event => {
document.querySelectorAll('pre code').forEach(block => {
hljs.highlightBlock(block)
})
})
document.addEventListener("DOMContentLoaded", (event) => {
document.querySelectorAll("pre code").forEach((element) => {
hljs.highlightElement(element);
});
});

View file

@ -13,8 +13,8 @@ x-assets: &default-assets
services:
css:
<<: *default-assets
command: "./run yarn:build:css"
command: "../run yarn:build:css"
js:
<<: *default-assets
command: "./run yarn:build:js"
command: "../run yarn:build:js"

View file

@ -1,28 +0,0 @@
const esbuild = require('esbuild')
let minify = false
let sourcemap = true
let watch_fs = true
if (process.env.NODE_ENV === 'production') {
minify = true
sourcemap = false
watch_fs = false
}
const watch = watch_fs && {
onRebuild(error) {
if (error) console.error('[watch] build failed', error)
else console.log('[watch] build finished')
},
}
esbuild.build({
entryPoints: ['./assets/js/app.js'],
outfile: './build/app.js',
bundle: true,
minify: minify,
sourcemap: sourcemap,
watch: watch,
plugins: [],
})

View file

@ -87,7 +87,7 @@ function yarn:build:css {
fi
tailwindcss --postcss \
-i assets/css/tailwind.pcss \
-i css/tailwind.pcss \
-o source/build/app.css "${args[@]}"
}