Skip to content

Commit

Permalink
feat: new env file support for next 9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
LasaleFamine committed May 22, 2020
1 parent de93173 commit 0c55300
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
6 changes: 5 additions & 1 deletion src/helpers/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ const filesWithDots = (name: string) => {
case 'yarnrc':
case 'npmrc':
case 'editorconfig':
case 'babelrc': {
case 'babelrc':
case 'env.development':
case 'env.production':
case 'env':
case 'env.local': {
return '.'.concat(name);
}
default: {
Expand Down
1 change: 1 addition & 0 deletions templates/next/env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_IS_DEV=true
1 change: 1 addition & 0 deletions templates/next/env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_IS_DEV=false
18 changes: 2 additions & 16 deletions templates/next/next.config.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
/*
eslint-disable
@typescript-eslint/no-var-requires,
no-param-reassign,
global-require
*/

const {
PHASE_DEVELOPMENT_SERVER,
} = require('next/constants');

module.exports = (phase) => {
// Started in development mode `yarn dev` regardless of the value of STAGING environmental variable
const isDev = phase === PHASE_DEVELOPMENT_SERVER || process.env.NODE_ENV === 'development';

const env = {
IS_DEV: isDev,
};

module.exports = () => {
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});

return withBundleAnalyzer({
env,
});
return withBundleAnalyzer();
};

0 comments on commit 0c55300

Please # to comment.