mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 17:55:08 +01:00
Use rewrites for tracker script name, closes #972
This commit is contained in:
parent
1e4c3ebf3b
commit
460762bf3d
@ -2,9 +2,12 @@
|
||||
FROM node:12.22-alpine AS build
|
||||
ARG BASE_PATH
|
||||
ARG DATABASE_TYPE
|
||||
ARG TRACKER_SCRIPT_NAME
|
||||
|
||||
ENV BASE_PATH=$BASE_PATH
|
||||
ENV DATABASE_URL "postgresql://umami:umami@db:5432/umami" \
|
||||
DATABASE_TYPE=$DATABASE_TYPE
|
||||
ENV DATABASE_URL "postgresql://umami:umami@db:5432/umami"
|
||||
ENV DATABASE_TYPE=$DATABASE_TYPE
|
||||
ENV TRACKER_SCRIPT_NAME=$TRACKER_SCRIPT_NAME
|
||||
WORKDIR /build
|
||||
|
||||
RUN yarn config set --home enableTelemetry 0
|
||||
|
@ -1,14 +1,16 @@
|
||||
require('dotenv').config();
|
||||
const pkg = require('./package.json');
|
||||
|
||||
const { BASE_PATH, FORCE_SSL, DISABLE_LOGIN, TRACKER_SCRIPT_NAME } = process.env;
|
||||
|
||||
module.exports = {
|
||||
env: {
|
||||
VERSION: pkg.version,
|
||||
FORCE_SSL: !!process.env.FORCE_SSL,
|
||||
DISABLE_LOGIN: !!process.env.DISABLE_LOGIN,
|
||||
TRACKER_SCRIPT_NAME: process.env.TRACKER_SCRIPT_NAME,
|
||||
FORCE_SSL: Boolean(FORCE_SSL),
|
||||
DISABLE_LOGIN: Boolean(DISABLE_LOGIN),
|
||||
TRACKER_SCRIPT_NAME,
|
||||
},
|
||||
basePath: process.env.BASE_PATH,
|
||||
basePath: BASE_PATH,
|
||||
eslint: {
|
||||
ignoreDuringBuilds: true,
|
||||
},
|
||||
@ -21,10 +23,15 @@ module.exports = {
|
||||
|
||||
return config;
|
||||
},
|
||||
async rewrites() {
|
||||
return TRACKER_SCRIPT_NAME
|
||||
? [{ source: `/${TRACKER_SCRIPT_NAME}.js`, destination: '/umami.js' }]
|
||||
: [];
|
||||
},
|
||||
async headers() {
|
||||
return [
|
||||
{
|
||||
source: '/umami.js',
|
||||
source: `/${TRACKER_SCRIPT_NAME || 'umami'}.js`,
|
||||
headers: [
|
||||
{
|
||||
key: 'Cache-Control',
|
||||
|
@ -3,12 +3,10 @@ import buble from '@rollup/plugin-buble';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import { terser } from 'rollup-plugin-terser';
|
||||
|
||||
const scriptName = process.env.TRACKER_SCRIPT_NAME || 'umami';
|
||||
|
||||
export default {
|
||||
input: 'tracker/index.js',
|
||||
output: {
|
||||
file: `public/${scriptName}.js`,
|
||||
file: 'public/umami.js',
|
||||
format: 'iife',
|
||||
},
|
||||
plugins: [resolve(), buble({ objectAssign: true }), terser({ compress: { evaluate: false } })],
|
||||
|
Loading…
Reference in New Issue
Block a user