diff --git a/Dockerfile b/Dockerfile index caacaced..843c44ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ FROM nginx:1.24.0-alpine RUN rm -r /usr/share/nginx/html && rm /etc/nginx/conf.d/default.conf # Copy pattern library static assets, and put them in nginx document root folder COPY --from=builder /frontend-shared/build /usr/share/nginx/html -COPY ./templates/pattern-library.mustache /usr/share/nginx/html/index.html +COPY ./templates/index.html /usr/share/nginx/html/index.html COPY ./images /usr/share/nginx/html/images COPY conf/nginx.conf /etc/nginx/conf.d/default.conf diff --git a/package.json b/package.json index a6655f79..039be0a8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ "karma-source-map-support": "^1.4.0", "mocha": "10.2.0", "mustache": "^4.2.0", - "mustache-express": "^1.3.0", "plop": "^3.1.1", "postcss": "^8.3.9", "preact": "^10.5.6", diff --git a/scripts/serve-pattern-library.js b/scripts/serve-pattern-library.js index db4d9f10..dfc9dc47 100644 --- a/scripts/serve-pattern-library.js +++ b/scripts/serve-pattern-library.js @@ -1,19 +1,20 @@ import express from 'express'; import log from 'fancy-log'; -import mustacheExpress from 'mustache-express'; import * as path from 'path'; import { fileURLToPath } from 'url'; export function servePatternLibrary(port = 4001) { const dirname = path.dirname(fileURLToPath(import.meta.url)); const app = express(); - app.engine('mustache', mustacheExpress()); - app.set('view engine', 'mustache'); - app.set('views', [path.join(dirname, '../templates')]); + + // Map paths from which we serve static files app.use('/scripts', express.static(path.join(dirname, '../build/scripts'))); app.use('/styles', express.static(path.join(dirname, '../build/styles'))); + app.use('/images', express.static(path.join(dirname, '../images'))); + + // For any other path, serve the index.html file to allow client-side routing app.get('/:path?', (req, res) => { - res.render('pattern-library'); + res.sendFile(path.join(dirname, '../templates/index.html')); }); app.listen(port, () => { diff --git a/tailwind.config.js b/tailwind.config.js index fb818896..11b149b4 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -5,5 +5,5 @@ import tailwindPreset from './src/tailwind.preset.js'; export default { presets: [tailwindPreset], - content: ['./src/**/*.{js,ts,tsx}', './templates/**/*.mustache'], + content: ['./src/**/*.{js,ts,tsx}', './templates/**/*.html'], }; diff --git a/templates/pattern-library.mustache b/templates/index.html similarity index 100% rename from templates/pattern-library.mustache rename to templates/index.html diff --git a/yarn.lock b/yarn.lock index 70835e4d..9da5d237 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1859,11 +1859,6 @@ async-settle@^1.0.0: dependencies: async-done "^1.2.2" -async@~3.2.0: - version "3.2.3" - resolved "https://registry.yarnpkg.com/async/-/async-3.2.3.tgz#ac53dafd3f4720ee9e8a160628f18ea91df196c9" - integrity sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g== - atob@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz" @@ -5454,7 +5449,7 @@ lower-case@^2.0.2: dependencies: tslib "^2.0.3" -lru-cache@^5.1.1, lru-cache@~5.1.1: +lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== @@ -5691,15 +5686,6 @@ ms@2.1.3: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== -mustache-express@^1.3.0: - version "1.3.2" - resolved "https://registry.yarnpkg.com/mustache-express/-/mustache-express-1.3.2.tgz#fe0aa129cfc42bfe6fa4dbd191eba5303ba04785" - integrity sha512-yAdGHctEq9ubUH7h9O6Z6kW35fwfE+7LpW/TBrcfVibZuiVRHDcK8DEydgiU5nlJmJUY5VC3jv2lzaPUL+Arkw== - dependencies: - async "~3.2.0" - lru-cache "~5.1.1" - mustache "^4.2.0" - mustache@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/mustache/-/mustache-4.2.0.tgz#e5892324d60a12ec9c2a73359edca52972bf6f64"