clh161 / react-router-sitemap-generator

15 stars 11 forks source link

babel-node Not supported in production build #156

Open behi1989 opened 1 year ago

behi1989 commented 1 year ago

I did this to create a sitemap

React package.json:

`

"scripts": {

    "build:staging": "env-cmd -f ./.env.staging npm run sitemap && react-scripts build",

    "build:production": "env-cmd -f ./.env.production npm run sitemap && react-scripts build",

    "sitemap": "babel-node ./src/utils/sitemapBuilder.js"

},

`

It works correctly in the stage environment, but it does not work in the production environment.

When Docker wants to build staging, this is the result < urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" > < url > < loc >https://url.com< /loc > < lastmod >2023-01-08< /lastmod > < changefreq >monthly< /changefreq > < priority >0.8< /priority > < /url > < url > < loc >https://url.com/contactus< /loc > < lastmod >2023-01-08< /lastmod > < changefreq >monthly< /changefreq > < priority >0.8< /priority > < /url > < url > < loc >https://url.com/about< /loc > < lastmod >2023-01-08< /lastmod > < changefreq >monthly< /changefreq > < priority >0.8< /priority > < /url > < /urlset >

When Docker wants to build production, this is the result < urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> < /urlset >

How should I solve this problem?