This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function useDebounce(func:() => any, args: Array<any>, delay:number = 250) { | |
| const [timeoutId, setTimeoutId] = useState<number>(); | |
| useEffect(() => { | |
| if (timeoutId !== undefined) | |
| clearInterval(timeoutId); | |
| //@ts-ignore | |
| setTimeoutId(setTimeout(() => { | |
| func(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface Entry { | |
| type: string | |
| } | |
| function isTypeOf<T extends Entry>(expectedType:string, testedEntry:T): testedEntry is T { | |
| return expectedType === testedEntry.type; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>My test page</title> | |
| <script> | |
| window.appConfig = { | |
| "CLIENT_NAME": "Client", | |
| "PRIMARY_COLOR": "green" | |
| }; | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3.4' | |
| services: | |
| client_a: | |
| build: | |
| context: ./ | |
| environment: | |
| PRIMARY_COLOR: green | |
| CLIENT_NAME: "Client A" | |
| ports: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM node:12 | |
| ENV PRIMARY_COLOR '' | |
| ENV CLIENT_NAME '' | |
| COPY . /app/ | |
| WORKDIR /app | |
| RUN npm install | |
| RUN npm run build | |
| RUN npm install -g env-serve | |
| EXPOSE 3000 | |
| WORKDIR /app/src |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const PRIMARY_COLOR = process.env.PRIMARY_COLOR || 'green'; | |
| // do some build stuff with webpack etc. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export PROJECT_VERSION=$(package.json | grep version | grep -oh -P '\d{1,2}\.\d{1,3}.\d{1,4}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { writeFileSync } = require('fs'); | |
| const { default: InjectPlugin } = require('webpack-inject-plugin'); | |
| /** | |
| * | |
| * @param config {Object} | |
| */ | |
| const logConfig = config => console.log('\nApp build with config: \n', JSON.stringify(config, null, 4)); | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CustomPlugin { | |
| constructor(name, stage, cb) { | |
| this.name = name; | |
| this.cb = cb; | |
| this.stage = stage; | |
| } | |
| apply(compiler) { | |
| compiler.hooks[this.stage].tap(this.name, () => { | |
| this.cb(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function memo(fn) { | |
| const cache = new Map(); | |
| return function(...params) { | |
| const paramsKey = JSON.stringify(params); | |
| if (cache.has(paramsKey)) | |
| return cache.get(paramsKey); | |
| const val = fn(...params); |