2021-12-11 14:04:05 +01:00
|
|
|
import path from 'path'
|
2022-07-12 20:47:39 +02:00
|
|
|
import { designs, plugins } from '../../../config/software/index.mjs'
|
2022-02-05 17:45:23 +01:00
|
|
|
|
2022-01-24 12:34:29 +01:00
|
|
|
/*
|
|
|
|
* This mehthod will return the NextJS configuration
|
|
|
|
* Parameters:
|
|
|
|
*
|
|
|
|
* site: one of 'dev', 'org', or 'lab'
|
|
|
|
*/
|
2023-10-07 09:27:54 +02:00
|
|
|
const config = ({ site }) => {
|
2023-05-15 15:57:46 +02:00
|
|
|
return {
|
|
|
|
experimental: {
|
|
|
|
externalDir: true,
|
|
|
|
},
|
|
|
|
pageExtensions: ['mjs'],
|
|
|
|
webpack: (config, options) => {
|
|
|
|
// Fixes npm packages that depend on node modules
|
|
|
|
if (!options.isServer) {
|
|
|
|
config.resolve.fallback.fs = false
|
|
|
|
config.resolve.fallback.path = false
|
|
|
|
config.resolve.fallback.child_process = false
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fix for nextjs bug #17806
|
|
|
|
config.module.rules.push({
|
|
|
|
test: /index.mjs$/,
|
|
|
|
type: 'javascript/auto',
|
|
|
|
resolve: {
|
|
|
|
fullySpecified: false,
|
|
|
|
},
|
|
|
|
})
|
2021-12-10 09:56:19 +01:00
|
|
|
|
2023-05-15 15:57:46 +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-06-17 12:02:09 +02:00
|
|
|
|
2023-05-15 15:57:46 +02:00
|
|
|
// Aliases
|
|
|
|
config.resolve.alias.shared = path.resolve('../shared/')
|
|
|
|
config.resolve.alias.site = path.resolve(`../${site}/`)
|
|
|
|
config.resolve.alias.markdown = path.resolve(`../../markdown/${site}/`)
|
2023-05-18 15:25:40 +02:00
|
|
|
config.resolve.alias.orgmarkdown = path.resolve(`../../markdown/org/`)
|
|
|
|
config.resolve.alias.devmarkdown = path.resolve(`../../markdown/dev}/`)
|
2023-05-15 15:57:46 +02:00
|
|
|
config.resolve.alias.config = path.resolve('../../config/')
|
|
|
|
config.resolve.alias.designs = path.resolve('../../designs/')
|
|
|
|
config.resolve.alias.plugins = path.resolve('../../plugins/')
|
|
|
|
config.resolve.alias.pkgs = path.resolve('../../packages/')
|
|
|
|
config.resolve.alias.root = path.resolve('../../')
|
2022-06-17 12:02:09 +02:00
|
|
|
|
2023-05-15 15:57:46 +02:00
|
|
|
// Load designs from source, rather than compiled package
|
|
|
|
for (const design in designs) {
|
|
|
|
config.resolve.alias[`@freesewing/${design}`] = path.resolve(
|
|
|
|
`../../designs/${design}/src/index.mjs`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
// Load plugins from source, rather than compiled package
|
|
|
|
for (const plugin in plugins) {
|
|
|
|
config.resolve.alias[`@freesewing/${plugin}`] = path.resolve(
|
|
|
|
`../../plugins/${plugin}/src/index.mjs`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
// Load these from source, rather than compiled package
|
2024-09-15 15:29:30 +02:00
|
|
|
for (const pkg of ['core', 'i18n', 'models', 'snapseries']) {
|
2023-05-15 15:57:46 +02:00
|
|
|
config.resolve.alias[`@freesewing/${pkg}`] = path.resolve(
|
|
|
|
`../../packages/${pkg}/src/index.mjs`
|
|
|
|
)
|
|
|
|
}
|
2021-12-11 14:04:05 +01:00
|
|
|
|
2023-05-15 15:57:46 +02:00
|
|
|
return config
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2021-12-10 09:56:19 +01:00
|
|
|
|
|
|
|
export default config
|