diff --git a/Dockerfile b/Dockerfile index f2fda55..0657397 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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/ @@ -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 diff --git a/next.config.js b/next.config.mjs similarity index 52% rename from next.config.js rename to next.config.mjs index f2fdbd6..0538b48 100644 --- a/next.config.js +++ b/next.config.mjs @@ -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 [ @@ -23,5 +28,6 @@ module.exports = withTM({ ]; }, output: 'standalone', - ...withBundleAnalyzer({}), -}); +})); + +export default nextConfig;