ionic-team / ionic-cli

The Ionic command-line interface
MIT License
2k stars 655 forks source link

Customize ionic build (e.g. using craco instead of react-scripts) #4627

Open Toub opened 3 years ago

Toub commented 3 years ago

In order to use tailwind, I would like to build the app using craco (see https://tailwindcss.com/docs/guides/create-react-app).

Is it possible to customize [https://ionicframework.com/docs/cli/commands/build](`ionic build`) command?

The documentation is not really clear about what does ionic build does, but it looks like it call "create scripts" build for react apps.

A workaround is to manually build the app, then running ionic capacitor build --no-buid : https://ionicframework.com/docs/cli/commands/capacitor-build

Is it the right way to customize the build today? A better build documentation (especially about customization) would be really really nice.

kelchm commented 3 years ago

I have not actually tested this, but I think this may be able to be accomplished by adding custom ionic:build, ionic:start, etc scripts to your package.json.

Something along the lines of:

"scripts": {
    "ionic:build": "craco build",
    "ionic:serve": "craco start",
    ....
}

This is (briefly) mentioned in the documentation here.

emersonsdo commented 3 years ago

That worked properly @kelchm. Thanks!

Indeed I wanna to find some way to create kind of a 'staging ionic build' that use the staging env file with react, and your tips will be very usefull.

haikyuu commented 3 years ago

Worked for me as well. Maybe we can add this to the docs in respective commands.

Otherwise the issue can be closed