1
0
Fork 0
freesewing/sites/org/next.config.mjs

35 lines
955 B
JavaScript
Raw Normal View History

2022-05-21 19:26:43 +02:00
import path from 'path'
import { readdirSync } from 'fs'
import i18nConfig from './next-i18next.config.js'
2022-11-23 21:42:22 +01:00
const getDirectories = (source) =>
2022-05-21 19:26:43 +02:00
readdirSync(source, { withFileTypes: true })
2022-11-23 21:42:22 +01:00
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name)
2022-05-21 19:26:43 +02:00
const pkgs = getDirectories(path.resolve(`../`))
const config = {
experimental: {
externalDir: true,
},
i18n: i18nConfig.i18n,
2022-11-23 21:42:22 +01:00
pageExtensions: ['js', 'mjs'],
2022-05-21 19:26:43 +02:00
webpack: (config, options) => {
// Aliases
config.resolve.alias.shared = path.resolve('../shared/')
2022-05-21 19:26:43 +02:00
config.resolve.alias.site = path.resolve(`.`)
config.resolve.alias.pkgs = path.resolve(`../../packages/`)
2022-05-21 19:26:43 +02:00
// This forces webpack to load the code from source, rather than compiled bundle
for (const pkg of pkgs) {
2022-11-23 21:42:22 +01:00
config.resolve.alias[`@freesewing/${pkg}$`] = path.resolve(
`../../packages/${pkg}/src/index.js`
)
2022-05-21 19:26:43 +02:00
}
return config
2022-11-23 21:42:22 +01:00
},
2022-05-21 19:26:43 +02:00
}
export default config