Here is the content of my next.config.mjs
file:
export default {
webpack: (config) => {
// Find rules that includes current directory
const rulesWithCurrentDir = config.module.rules.filter((rule) => rule.include && rule.include.includes(__dirname))
// Prepare the sibling package paths that we want to include
const apiPath = path.resolve(`${__dirname}../../api`)
const siblingPackagePaths = [apiPath]
// Push sibling package paths
rulesWithCurrentDir.forEach((ruleWithCurrentDir) => ruleWithCurrentDir.include.push(...siblingPackagePaths))
return config
},
}
As for the babel.config.mjs
file:
export default {
presets: ["@babel/preset-env", '@babel/preset-typescript', "@babel/preset-react"],
plugins: [
[
'babel-plugin-transform-imports',
{
lodash: {
transform: 'lodash/${member}',
preventFullImport: true,
},
'@mui/material': {
transform: '@mui/material/${member}',
preventFullImport: true,
},
'@mui/icons-material': {
transform: '@mui/icons-material/${member}',
preventFullImport: true,
},
'@mui/lab': {
transform: '@mui/lab/${member}',
preventFullImport: true,
},
<snip>
}
Encountered an error while running yarn build
:
../api/src/components/ModelAutocompleteField.tsx
Module parse failed: Unexpected token (6:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| import { AutocompleteProps, CircularProgress, TextField, TextFieldProps } from '@mui/material'
|
> export interface OptionType {
| id: string
| title?: string