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