Ionic-cli: Customize ionic build (e.g. using craco instead of react-scripts)

Created on 28 Dec 2020  路  3Comments  路  Source: ionic-team/ionic-cli

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 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.

triage

Most helpful comment

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.

All 3 comments

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.

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.

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

Otherwise the issue can be closed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rashnk picture rashnk  路  3Comments

zoinkydoink picture zoinkydoink  路  3Comments

patwaswapnil picture patwaswapnil  路  3Comments

mpaland picture mpaland  路  3Comments

phyr0s picture phyr0s  路  3Comments