dilanx / craco

Create React App Configuration Override, an easy and comprehensible configuration layer for Create React App.

Home Page:https://craco.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

craco changes the output content of the package file to package the original configuration file and own custom folder

TaoistYG opened this issue · comments

What's happening
Hello, When I use craco to change the package file name and static resource directory,The packaging generates not only the original default build file, but also my own custom folder,The default build file is a file directory after deployment, and dist is a normal file

What should happen
I want to package to generate only custom folders and directories

To reproduce
npm i @craco/craco -D
npm run build

CRACO version
(ex. 7.1.0)

CRACO config

const path = require('path');
const addPath = dir => path.join(__dirname, dir);
const { whenProd } = require('@craco/craco')

const webpackConfig = {
    webpack: {
        alias: {
            "@": addPath("src"),
        },
        configure: (webpackConfig, { env, paths }) => {
            path.appBuild = 'dist'; 
            webpackConfig.output = {
                ...webpackConfig.output,
                path: path.resolve(__dirname, 'dist'), 
                publicPath: '/',
            }
            webpackConfig.output.path = path.resolve(__dirname, 'dist');
            return webpackConfig;
        }
    },
    babel: {
        plugins: [
            // ['import', { libraryName: 'antd', style: true}],  
        ]
    }
}

module.exports = webpackConfig;

package.json

"dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "@types/jest": "^27.5.2",
    "@types/node": "^16.18.14",
    "@types/nprogress": "^0.2.0",
    "@types/react": "^18.0.28",
    "@types/react-dom": "^18.0.11",
    "@types/react-router-dom": "^5.3.3",
    "antd": "^5.3.1",
    "axios": "^1.3.4",
    "mobx": "^6.8.0",
    "mobx-react": "^7.6.0",
    "nprogress": "^0.2.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.8.2",
    "react-scripts": "5.0.1",
    "typescript": "^4.9.5",
 },
"scripts": {
    "start": "craco start",
    "build": "craco build",
    "test": "craco test",
    "eject": "react-scripts eject"
 },
"devDependencies": {
    "@babel/plugin-proposal-decorators": "^7.21.0",
    "@craco/craco": "^7.1.0",
    "babel-plugin-import": "^1.13.6"
 }

Additional information
I think it may be a problem between react- Script 5.x and Craco 7.x