Using components from the strapi-plugin-content-manager

System Information
  • Strapi Version: 3.4.1
  • Operating System: macOS
  • Database: Mysql
  • Node Version: 14
  • NPM Version: 6.14

I’d like to customize the homepage of strapi and show a list of articles. Rather than create the list my self I looked at how the content types are made and I found the CustomTable component. I’ve created the file ./admin/src/containers/HomePage/index.js and I tried to import the component like that:

import CustomTable from 'strapi-plugin-content-manager/admin/src/components/CustomTable';

I launched the npm run develop command and I’ve got the error:

error  in ./node_modules/strapi-plugin-content-manager/admin/src/components/CustomTable/index.js

Module parse failed: Unexpected token (49:19)
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
|             const isPublished = !isEmpty(cellData.published_at);
| 
>             return <State isPublished={isPublished} />;
|           },
|         },

 @ ./.cache/admin/src/containers/HomePage/index.js 28:42-115
 @ ./.cache/admin/src/containers/Admin/index.js
 @ ./.cache/admin/src/containers/App/index.js
 @ ./.cache/admin/src/app.js

The admin pages seem to work fine, is there something I do wrong or it requires a specific webpack build?

Thank you

1 Like

I’d also like to be able to reuse components from strapi. There’s no documentation or anything about how to build interfaces or use their component system. I wonder if this is a planned feature?

Managed to get around the issue by modifying the webpack config, apparently node_modules is being ignored by babel.

Here’s the admin.config.js that should go in the ./admin directory in the project:
pastebin

2 Likes

Yes. It’s work. Thank you very much.

FREEZX Thank you very march!

This git I’m using to debug my Field API component using FREEZX’s webpack config:

I’m trying something similar in v4 but not importing from strapi-plugin-content-manager, instead I want to access these components @strapi/admin/admin/src/content-manager/components

import NonRepeatableComponent from "@strapi/admin/admin/src/content-manager/components/NonRepeatableComponent";

But I’m getting this error

ERROR in ./node_modules/@strapi/admin/admin/src/content-manager/components/NonRepeatableComponent/index.js 22:4
Module parse failed: Unexpected token (22: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

Is there any webpack config needed here