think/packages/client/next.config.js

53 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-05-01 16:15:13 +00:00
const semi = require('@douyinfe/semi-next').default({});
2022-03-12 02:31:03 +00:00
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
2022-05-18 08:50:42 +00:00
const withOffline = require('next-offline');
2022-03-12 02:31:03 +00:00
const { getConfig } = require('@think/config');
2022-03-26 14:02:26 +00:00
const config = getConfig();
2022-02-20 11:51:55 +00:00
2022-05-01 16:15:13 +00:00
/** @type {import('next').NextConfig} */
const nextConfig = semi({
2022-02-20 11:51:55 +00:00
assetPrefix: config.assetPrefix,
env: {
2022-05-01 16:15:13 +00:00
SERVER_API_URL: config.client.apiUrl,
COLLABORATION_API_URL: config.client.collaborationUrl,
ENABLE_ALIYUN_OSS: !!config.oss.aliyun.accessKeyId,
2022-05-11 06:05:11 +00:00
DRAWIO_URL: config.client.drawioUrl || 'https://embed.diagrams.net',
2022-02-20 11:51:55 +00:00
},
webpack: (config, { dev, isServer }) => {
config.resolve.plugins.push(new TsconfigPathsPlugin());
return config;
},
eslint: {
ignoreDuringBuilds: true,
},
2022-03-21 11:55:06 +00:00
// FIXME: douyinfe 的第三方包存在 ts 类型错误!
typescript: {
ignoreBuildErrors: true,
},
2022-05-18 09:04:08 +00:00
compiler: {
2022-05-18 13:14:18 +00:00
removeConsole: true,
2022-05-18 09:04:08 +00:00
},
2022-05-18 08:50:42 +00:00
workboxOpts: {
runtimeCaching: [
{
urlPattern: /.(png|jpg|jpeg|svg|webp)$/,
handler: 'CacheFirst',
},
{
urlPattern: /api/,
handler: 'NetworkFirst',
options: {
cacheableResponse: {
statuses: [0, 200],
headers: {
'x-sw': 'true',
},
},
},
},
],
},
2022-02-20 11:51:55 +00:00
});
2022-05-18 08:50:42 +00:00
module.exports = withOffline(nextConfig);