Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate pre-existing build outputs from runtime build outputs #379

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ node_modules
.env

# Dist folder
dist/*
!dist/favicon.ico
!dist/index.css
!dist/index.js
!dist/tracker.js
/dist

# Files not required by Docker
Dockerfile
Expand Down
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ node_modules
.env

# Dist folder
dist/*
!dist/favicon.ico
!dist/index.css
!dist/index.js
!dist/tracker.js
/dist

# Vercel
.vercel
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN yarn install --production --frozen-lockfile --network-timeout 120000

COPY build.js /srv/app/
COPY src /srv/app/src
COPY dist /srv/app/dist
COPY public /srv/app/public

# Start with second build stage

Expand Down
16 changes: 13 additions & 3 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@
'use strict'
require('dotenv').config()

const fs = require('fs')

const config = require('./src/utils/config')
const customTracker = require('./src/utils/customTracker')
const { index, styles, scripts, tracker, build } = require('./src/ui/index')

// Build files that are identical on every installation
if (config.isPreBuildMode === true) {
build('dist/index.css', styles)
build('dist/index.js', scripts)
build('dist/tracker.js', tracker)
build('public/index.css', styles)
build('public/index.js', scripts)
build('public/tracker.js', tracker)
}

// create dist if needed
if (!fs.existsSync('dist')) fs.mkdirSync('dist')

// copy public files to dist
fs.readdirSync('public').forEach(filename => {
fs.copyFileSync(`public/${filename}`, `dist/${filename}`)
})

// Build files that depend on environment variables
build(`dist/index.html`, index)
if (customTracker.exists === true) build(`dist/${ customTracker.path }`, tracker)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.