react-app-rewired start works but not build

Viewed 294

I have been having an issue with my website where I run "yarn start" and the site runs just fine. When I use the command "yarn build" all my images are placed inside the build folder but it does not add the index or any of the static stuff.

These are my scripts.

"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",

When I change the build script to "build": "react-scripts build" I get the error

Cannot find module: 'components/header'. Make sure this package is 
installed.

You can install this package by running: yarn add components/header.

My site uses babel to map these imports

config-overrides.js

const { useBabelRc, override, addWebpackModuleRule } = require('customize-cra');

const isDev = process.env.NODE_ENV === 'development';

module.exports = override(
  useBabelRc(),
  addWebpackModuleRule({
    test: /\.tsx?$/,
    exclude: /node_modules/,
    use: [
      { loader: 'babel-loader' },
      {
        loader: '@linaria/webpack-loader',
        options: {
          cacheDirectory: 'src/.linaria_cache',
          sourceMap: isDev,
        },
      },
    ],
  }),
  addWebpackModuleRule({
    test: /-icon\.svg$/,
    use: ['@svgr/webpack'],
  })
);
module.exports = {
  presets: [['react-app', { flow: false, typescript: true }], '@linaria'],
  plugins: [
    ['@babel/plugin-proposal-private-methods', { loose: true }],
    ['@babel/plugin-proposal-class-properties', { loose: true }],
    [
      'module-resolver',
      {
        root: ['./src'],
        alias: {
          components: './src/components',
          styles: './src/styles',
          assets: './src/assets',
        },
      },
    ],
  ],
};

When I use yarn build as normal it just loads normal and then says done. is their any reason why this works with yarn start and not build?

0 Answers
Related