Generate minified CSS/JS in the Docker build, remove unused assets
- New 'assets' stage in the Dockerfile builds style.min.css and functions.min.js from the sources (npm run build:min); they are no longer committed, so they can't go stale anymore - Production (APP_DEBUG off) loads the minified files, local development the readable ones, both with a cache-busting version (AssetHelper, Asset::url() in the layout) - Source maps are excluded from the image - Remove unused assets: public/css/old, public/js/old and unused copies of jQuery, wavesurfer, prettyPhoto (min) and mediaplayer_with_plugins - npm scripts: build:css (committed CSS), build:min (Docker build); sass-minify scripts removed - readme: how the CSS/JS build works Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b399e8bc76
commit
f7b1dbac8f
83 files changed
+72
-17741
No files matched your search
+14
@@ -1,3 +1,13 @@
|
||||
# Build the minified CSS/JS (style.min.css, functions.min.js) from the sources.
|
||||
# Needs the npm devDependencies (sass, grunt), which the final image doesn't get.
|
||||
FROM node:20-alpine AS assets
|
||||
WORKDIR /build
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci --ignore-scripts
|
||||
COPY Gruntfile.cjs ./
|
||||
COPY resources/assets ./resources/assets
|
||||
RUN mkdir -p public/css public/js && npm run build:min
|
||||
|
||||
FROM php:8.3.37-apache
|
||||
|
||||
# Install Node.js
|
||||
@@ -64,6 +74,10 @@ RUN npm ci --omit=dev --ignore-scripts
|
||||
# Copy app files
|
||||
COPY . .
|
||||
|
||||
# Minified CSS/JS from the 'assets' stage (generated, not in git)
|
||||
COPY --from=assets /build/public/css/style.min.css public/css/
|
||||
COPY --from=assets /build/public/js/functions.min.js public/js/
|
||||
|
||||
# Create storage directories
|
||||
RUN mkdir -p \
|
||||
storage/app \
|
||||
|
||||
Reference in new issue
Block a user