Skip to content

Commit

Permalink
build: use next.config.mjs instead of cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheChristophe committed Sep 14, 2023
1 parent 8a3207a commit 64c1ba3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM node:18 as git-version

WORKDIR /app
COPY utils utils
COPY ["package.json", "yarn.lock", "next.config.js", "next-env.d.ts", "tsconfig.json", ".eslintrc.json", ".prettierrc", "./"]
COPY ["package.json", "yarn.lock", "next.config.mjs", "next-env.d.ts", "tsconfig.json", ".eslintrc.json", ".prettierrc", "./"]

# determine footer version
COPY .git/ ./.git/
Expand All @@ -13,7 +13,7 @@ FROM node:18 as base

WORKDIR /app

COPY ["package.json", "yarn.lock", "next.config.js", "next-env.d.ts", "tsconfig.json", ".eslintrc.json", ".prettierrc", "./"]
COPY ["package.json", "yarn.lock", "next.config.mjs", "next-env.d.ts", "tsconfig.json", ".eslintrc.json", ".prettierrc", "./"]
ENV NEXT_TELEMETRY_DISABLED=1
RUN yarn install
# copy necessary files
Expand Down
20 changes: 13 additions & 7 deletions next.config.js → next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
let withBundleAnalyzer = undefined;
import withBundleAnalyzer from '@next/bundle-analyzer';
import transpileModules from 'next-transpile-modules';

/** @typedef {import('next').NextConfig} NextConfig */

let bundleAnalyzer;
try {
withBundleAnalyzer = require('@next/bundle-analyzer')({
bundleAnalyzer = withBundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
});
} catch (e) {
console.log('No @next/bundle-analyzer, assuming production');
withBundleAnalyzer = () => {};
bundleAnalyzer = x => x;
}

const withTM = require('next-transpile-modules')(['echarts', 'zrender']);
const withTM = transpileModules(['echarts', 'zrender']);

/** @type {import('next').NextConfig} */
module.exports = withTM({
const nextConfig = bundleAnalyzer(withTM({
reactStrictMode: true,
async redirects() {
return [
Expand All @@ -23,5 +28,6 @@ module.exports = withTM({
];
},
output: 'standalone',
...withBundleAnalyzer({}),
});
}));

export default nextConfig;

0 comments on commit 64c1ba3

Please sign in to comment.