risen228 / craco-alias

A craco plugin for automatic aliases generation for Webpack and Jest
MIT License
109 stars 11 forks source link

Module not found: Can't resolve '@alias' in... #12

Closed anking closed 4 years ago

anking commented 4 years ago

Looks like I'm unable to use aliases at all.

comes up with an error:

Module not found: Can't resolve '@alias' in...

package,json

{
  "name": "zoomdashboard",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@craco/craco": "^5.6.4",
    "@material-ui/core": "^4.9.12",
    "babel-eslint": "^10.1.0",
    "bootstrap": "^4.4.1",
    "jquery": "^3.4.1",
    "merge": "^1.2.1",
    "oidc-client": "^1.9.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-router-bootstrap": "^0.24.4",
    "react-router-dom": "^4.2.2",
    "react-scripts": "^3.4.1",
    "reactstrap": "^6.3.0",
    "rimraf": "^2.6.2",
    "universal-cookie": "^4.0.3"
  },
  "devDependencies": {
    "ajv": "^6.12.2",
    "craco-alias": "^2.1.1",
    "cross-env": "^5.2.1",
    "eslint": "^6.6.0",
    "eslint-config-react-app": "^5.2.1",
    "eslint-plugin-flowtype": "^4.7.0",
    "eslint-plugin-import": "^2.20.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-react": "^7.19.0",
    "typescript": "^3.8.3"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "scripts": {
    "start": "rimraf ./build && craco start",
    "build": "craco build",
    "test": "cross-env CI=true craco test --env=jsdom",
    "eject": "react-scripts eject",
    "lint": "eslint ./src/"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

craco.config.js

module.exports = {
    plugins: [
        {
            plugin: CracoAlias,
            debug: true,
            options: {
                source: "options",
                baseUrl: "./",
                aliases: {
                    "@alias/*": "./src/components/Common/*"
                }
            }
        }
    ]
};
DanielDanaee commented 3 years ago

What was the fix?