
This suppresses a warning in webpack v5 when importing the version from the package.json file like a named export. This use to be fine in webpack v4 but in v5 it's deprecated to be more inline with the way it works in NodeJS. That being said, it's very usefull as there's no need to pull in the entire package.json file. Futhermore, esbuild supports this out of the box so we also use it in our build scripts. So for now I'm supressing this warning. In FreeSewing v3 we'll re-evaluate this.
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
import path from 'path'
|
|
import { readdirSync } from 'fs'
|
|
import i18nConfig from './next-i18next.config.js'
|
|
|
|
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,
|
|
pageExtensions: [ 'js' ],
|
|
webpack: (config, options) => {
|
|
|
|
// YAML support
|
|
config.module.rules.push({
|
|
test: /\.ya?ml$/,
|
|
type: 'json',
|
|
use: 'yaml-loader'
|
|
})
|
|
|
|
// 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/
|
|
]
|
|
|
|
// Aliases
|
|
config.resolve.alias.shared = path.resolve('../freesewing.shared/')
|
|
config.resolve.alias.site = path.resolve(`.`)
|
|
config.resolve.alias.lib = path.resolve(`./lib`)
|
|
config.resolve.alias.pkgs = path.resolve(`../`)
|
|
// This forces webpack to load the code from source, rather than compiled bundle
|
|
for (const pkg of pkgs) {
|
|
config.resolve.alias[`@freesewing/${pkg}$`] = path.resolve(`../${pkg}/src/index.js`)
|
|
}
|
|
|
|
return config
|
|
}
|
|
}
|
|
export default config
|