Skip to content

Commit

Permalink
Use next.config.mjs (#626)
Browse files Browse the repository at this point in the history
* Use next.config.mjs

* Simplify
  • Loading branch information
Janpot authored Jul 4, 2022
1 parent 3d34eab commit ac031f7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/**
* @param {string} input
* @returns {input is import('./src/config').ToolpadTargetType}
*/
function isValidTarget(input) {
return input === 'CLOUD' || input === 'CE' || input === 'PRO';
}

/** @type {(env: Partial<Record<string, string>>) => import('./src/config').BuildEnvVars} */
function parseBuidEnvVars(env) {
/** @type {import('./src/config').ToolpadTargetType} */
let target = 'CE';
if (env.TOOLPAD_TARGET && !isValidTarget(env.TOOLPAD_TARGET)) {
if (isValidTarget(env.TOOLPAD_TARGET)) {
Expand All @@ -20,12 +18,11 @@ function parseBuidEnvVars(env) {

return {
TOOLPAD_TARGET: target,
TOOLPAD_DEMO: env.TOOLPAD_DEMO === 'true',
TOOLPAD_DEMO: env.TOOLPAD_DEMO,
};
}

/** @type {import('next').NextConfig} */
module.exports = {
export default /** @type {import('next').NextConfig} */ ({
reactStrictMode: true,

eslint: {
Expand Down Expand Up @@ -66,4 +63,4 @@ module.exports = {
},
];
},
};
});
7 changes: 1 addition & 6 deletions packages/toolpad-app/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ import { RUNTIME_CONFIG_WINDOW_PROPERTY } from './constants';
* - Use by importing the module `./src/server.config`
*/

export type ToolpadTargetType = 'CLOUD' | 'CE' | 'PRO';

// These are inlined at build time
export interface BuildEnvVars {
TOOLPAD_TARGET: ToolpadTargetType;
TOOLPAD_DEMO: boolean;
}
export type BuildEnvVars = Partial<Record<'TOOLPAD_TARGET' | 'TOOLPAD_DEMO', string>>;

// These are set at runtime and passed to the browser.
// Do not add secrets
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"incremental": true,
"noUnusedLocals": true
},
"include": ["next.config.js", "next-env.d.ts", "**/*.ts", "**/*.tsx", "typings/**/*.d.ts"],
"include": ["next.config.mjs", "next-env.d.ts", "**/*.ts", "**/*.tsx", "typings/**/*.d.ts"],
"exclude": ["node_modules", "./scripts", "./public"]
}

0 comments on commit ac031f7

Please sign in to comment.