2022-05-21 19:26:43 +02:00
|
|
|
import path from 'path'
|
|
|
|
import { readdirSync } from 'fs'
|
|
|
|
import i18nConfig from './next-i18next.config.js'
|
2022-01-02 17:16:15 +01:00
|
|
|
|
2022-05-21 19:26:43 +02:00
|
|
|
const getDirectories = source =>
|
|
|
|
readdirSync(source, { withFileTypes: true })
|
|
|
|
.filter(dirent => dirent.isDirectory())
|
|
|
|
.map(dirent => dirent.name)
|
|
|
|
|
|
|
|
const pkgs = getDirectories(path.resolve(`../`))
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
experimental: {
|
|
|
|
externalDir: true,
|
|
|
|
},
|
|
|
|
i18n: i18nConfig.i18n,
|
2022-06-19 18:17:20 +00:00
|
|
|
pageExtensions: [ 'js', 'mjs' ],
|
2022-05-21 19:26:43 +02:00
|
|
|
webpack: (config, options) => {
|
2022-06-12 22:37:04 +02:00
|
|
|
|
2022-05-21 19:26:43 +02:00
|
|
|
// Aliases
|
2022-07-11 18:26:08 +02:00
|
|
|
config.resolve.alias.shared = path.resolve('../shared/')
|
2022-05-21 19:26:43 +02:00
|
|
|
config.resolve.alias.site = path.resolve(`.`)
|
2022-07-11 18:26:08 +02:00
|
|
|
config.resolve.alias.pkgs = path.resolve(`../../packages/`)
|
2022-06-12 22:37:04 +02:00
|
|
|
|
|
|
|
// Suppress warnings about importing version from package.json
|
|
|
|
// We'll deal with it in v3 of FreeSewing
|
|
|
|
config.ignoreWarnings = [
|
|
|
|
/only default export is available soon/
|
|
|
|
]
|
|
|
|
|
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-07-11 18:26:08 +02:00
|
|
|
config.resolve.alias[`@freesewing/${pkg}$`] = path.resolve(`../../packages/${pkg}/src/index.js`)
|
2022-05-21 19:26:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return config
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export default config
|