Home > Software design >  Webpack stuck at compiling
Webpack stuck at compiling

Time:01-04

I'm using craco to override the create-react-app webpack config because I need to build my app as a micro-app.

My overrides :

module.exports = {
  webpack: {
    configure: (config) => {
      console.log(config);
      return {
        ...config,
        entry: {
          app: "./src/app.js", // the entry point of my micro-app
          main: "./src/index.js", // the entry point of my standalone app
        },
        experiments: {
          outputModule: true,
        },
        output: {
          library: {
            type: "module",
          },
          filename: "[name].js",
          path: __dirname   "/dist",
        },
      };
    },
  },
};

When I'm running craco start (as npm start) everything is good :

    Compiled successfully!
    
    You can now view timeline-app in the browser.    
    
    https://localhost:3000                 
    
    Note that the development build is not optimized.
    To create a production build, use npm run build. 
    
    webpack compiled successfully

and when I change something in the code : compiling...

CodePudding user response:

After a a long research, i discoverd I made a mistake when I deleted the "browserslist" key in package.json.

The default target config of CRACO (and Create React App) is "browserlist". so here the solution :

craco.config.js is the same.

package.json :

"browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
}
  • Related