Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dvhb/craco-extend-scope
https://github.com/dvhb/craco-extend-scope
Last synced: about 7 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/dvhb/craco-extend-scope
- Owner: dvhb
- License: mit
- Created: 2019-03-21T08:26:02.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-21T09:01:27.000Z (almost 6 years ago)
- Last Synced: 2024-11-05T18:29:45.227Z (about 2 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Craco extend scope plugin
By default [create-react-app](https://facebook.github.io/create-react-app/) don't allow you to import modules outside of
`/src` dir, it throws error like this:
`Relative imports outside of src/ are not supported`. This plugin extends CRA config to add custom paths to
[ModuleScopePlugin](https://github.com/facebook/create-react-app/tree/master/packages/react-dev-utils#new-modulescopepluginappsrc-string--string-allowedfiles-string).## Supported Versions
`craco-extend-scope` is tested with:
- `react-scripts`: `^2.1.5`
- `@craco/craco`: `^3.5.0`## Installation
First, follow the [`craco` Installation Instructions](https://github.com/sharegate/craco/blob/master/packages/craco/README.md##installation)
to install the `craco` package, create a `craco.config.js` file, and modify the scripts in your `package.json`.Then install `craco-extend-scope`:
```bash
$ npm i @dvhb/craco-extend-scope# OR
$ yarn add @dvhb/craco-extend-scope
```## Usage
Here is a complete `craco.config.js` configuration file that extends scope of `create-react-app`:
```js
const cracoExtendScope = require('@dvhb/craco-extend-scope');module.exports = {
plugins: [{ plugin: cracoExtendScope, options: { path: 'static' } }]
};
```Now you can use absolute import in you code like this:
```js
import 'static/styles.css';
```