2022-09-09 11:53:35 +00:00
|
|
|
import { defineConfig, AstroUserConfig } from 'astro/config'
|
|
|
|
import vercel from '@astrojs/vercel/serverless'
|
|
|
|
import solidJs from '@astrojs/solid-js'
|
|
|
|
import type { CSSOptions } from 'vite'
|
2022-11-13 06:41:04 +00:00
|
|
|
import { generateScopedNameDefault } from 'postcss-modules/build/scoping'
|
2022-09-23 19:03:20 +00:00
|
|
|
import { isDev } from './src/utils/config'
|
2022-10-07 08:04:26 +00:00
|
|
|
import { visualizer } from 'rollup-plugin-visualizer'
|
2022-09-09 11:53:35 +00:00
|
|
|
|
2022-09-23 19:53:05 +00:00
|
|
|
const PATH_PREFIX = '/src/'
|
2022-09-23 19:03:20 +00:00
|
|
|
|
|
|
|
const getDevCssClassPrefix = (filename: string): string => {
|
|
|
|
return filename
|
|
|
|
.slice(filename.indexOf(PATH_PREFIX) + PATH_PREFIX.length)
|
|
|
|
.replace('.module.scss', '')
|
2022-09-29 10:08:22 +00:00
|
|
|
.replace(/[/?\\]/g, '-')
|
2022-09-23 19:03:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const devGenerateScopedName = (name: string, filename: string, css: string) =>
|
2022-11-13 06:41:04 +00:00
|
|
|
getDevCssClassPrefix(filename) + '_' + generateScopedNameDefault(name, filename, css)
|
2022-09-09 11:53:35 +00:00
|
|
|
|
2022-09-22 09:37:49 +00:00
|
|
|
const css: CSSOptions = {
|
|
|
|
preprocessorOptions: {
|
|
|
|
scss: {
|
|
|
|
additionalData: '@import "src/styles/imports";\n'
|
|
|
|
}
|
2022-09-23 19:03:20 +00:00
|
|
|
},
|
|
|
|
modules: {
|
2022-11-13 06:41:04 +00:00
|
|
|
generateScopedName: isDev ? devGenerateScopedName : generateScopedNameDefault,
|
2022-09-23 19:03:20 +00:00
|
|
|
localsConvention: null
|
2022-09-22 09:37:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-09 11:53:35 +00:00
|
|
|
const astroConfig: AstroUserConfig = {
|
|
|
|
site: 'https://new.discours.io',
|
2022-10-07 11:02:34 +00:00
|
|
|
integrations: [solidJs()],
|
2022-09-09 11:53:35 +00:00
|
|
|
output: 'server',
|
|
|
|
adapter: vercel(),
|
|
|
|
vite: {
|
|
|
|
build: {
|
|
|
|
rollupOptions: {
|
2022-10-07 09:23:19 +00:00
|
|
|
plugins: [visualizer()],
|
2022-10-07 08:04:26 +00:00
|
|
|
output: {
|
2022-10-07 09:23:19 +00:00
|
|
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
2022-10-23 17:04:17 +00:00
|
|
|
/*
|
2022-10-07 08:04:26 +00:00
|
|
|
manualChunks(id) {
|
2022-10-09 09:07:13 +00:00
|
|
|
if (id.includes('p2p')) return 'p2p'
|
|
|
|
if (id.includes('editor') || id.includes('Editor')) return 'editor'
|
2022-10-07 08:04:26 +00:00
|
|
|
if (id.includes('node_modules')) {
|
2022-10-07 19:35:53 +00:00
|
|
|
let chunkid
|
2022-10-09 09:07:13 +00:00
|
|
|
if (id.includes('solid')) chunkid = 'solid'
|
|
|
|
if (id.includes('swiper')) chunkid = 'swiper'
|
|
|
|
if (id.includes('acorn')) chunkid = 'acorn'
|
|
|
|
if (id.includes('prosemirror')) chunkid = 'editor'
|
|
|
|
if (id.includes('markdown') || id.includes('mdurl') || id.includes('yjs')) {
|
|
|
|
chunkid = 'codecs'
|
2022-10-07 08:04:26 +00:00
|
|
|
}
|
2022-10-07 09:23:19 +00:00
|
|
|
if (
|
2022-10-09 09:07:13 +00:00
|
|
|
id.includes('p2p') ||
|
2022-10-07 09:23:19 +00:00
|
|
|
id.includes('y-protocols') ||
|
2022-10-07 19:35:53 +00:00
|
|
|
id.includes('y-webrtc') ||
|
|
|
|
id.includes('simple-peer')
|
2022-10-07 09:23:19 +00:00
|
|
|
) {
|
2022-10-07 19:35:53 +00:00
|
|
|
chunkid = 'p2p'
|
2022-10-07 08:04:26 +00:00
|
|
|
}
|
|
|
|
return chunkid
|
|
|
|
}
|
|
|
|
}
|
2022-10-23 17:04:17 +00:00
|
|
|
*/
|
2022-10-07 08:04:26 +00:00
|
|
|
},
|
2022-09-09 11:53:35 +00:00
|
|
|
external: ['@aws-sdk/clients/s3']
|
|
|
|
}
|
|
|
|
},
|
2022-09-22 09:37:49 +00:00
|
|
|
css
|
2022-09-09 11:53:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// https://astro.build/config
|
|
|
|
export default defineConfig(astroConfig)
|