【发布时间】:2022-10-18 13:13:05
【问题描述】:
我希望将一些 nextjs 组件导出到一个“commons”项目中,许多 nextjs 应用程序都将使用该项目。
所以,我将它添加到我的 package.json
"commons-project": "../commons-project",
我更改了组件导入以使用公共组件。例如:
import MyComponent from 'commons-project/components/my-component';
但是,我的项目不再编译了。这是完整的错误:
Module parse failed: Unexpected token (21:4)
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
|
| return (
> <Box mb={1} flex={1} display="flex" alignItems="center"
| justifyContent="center" className={classes.buttonRoot}
| style={{backgroundColor: bgColor ? bgColor : '#C3AEF8',
盒子来自@material-ui/core
我试图添加一个 webpack.config.js,并尝试这样的事情:
module.exports = {
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: [/node_modules/],
loader: 'babel-loader',
},
],
},
}
但我不明白如何正确配置 webpack。
【问题讨论】:
标签: webpack next.js material-ui