Use custom build output folder when using create-react-app

后端 未结 13 914
被撕碎了的回忆
被撕碎了的回忆 2020-12-04 17:24

Facebook provides a create-react-app command to build react apps. When we run npm run build, we see output in /build folder.

13条回答
  •  死守一世寂寞
    2020-12-04 18:04

    Open Command Prompt inside your Application's source. Run the Command

    npm run eject

    Open your scripts/build.js file and add this at the beginning of the file after 'use strict' line

    'use strict';
    ....
    process.env.PUBLIC_URL = './' 
    // Provide the current path
    .....
    

    Open your config/paths.js and modify the buildApp property in the exports object to your destination folder. (Here, I provide 'react-app-scss' as the destination folder)

    module.exports = {
    .....
    appBuild: resolveApp('build/react-app-scss'),
    .....
    }
    

    Run

    npm run build

    Note: Running Platform dependent scripts are not advisable

提交回复
热议问题