https://github.com/imcuttle/suffix-resolve-plugin
enhanced-resolve 插件,为了支持 resolve 不同优先级后缀路径
https://github.com/imcuttle/suffix-resolve-plugin
Last synced: 11 months ago
JSON representation
enhanced-resolve 插件,为了支持 resolve 不同优先级后缀路径
- Host: GitHub
- URL: https://github.com/imcuttle/suffix-resolve-plugin
- Owner: imcuttle
- License: mit
- Created: 2021-12-13T03:57:30.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-07T14:13:12.000Z (over 4 years ago)
- Last Synced: 2025-04-25T14:09:41.932Z (about 1 year ago)
- Language: TypeScript
- Size: 71.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: License
Awesome Lists containing this project
README
# suffix-resolve-plugin
[](https://travis-ci.com/余聪/suffix-resolve-plugin)
[](https://codecov.io/github/余聪/suffix-resolve-plugin?branch=master)
[](https://www.npmjs.com/package/suffix-resolve-plugin)
[](https://www.npmjs.com/package/suffix-resolve-plugin)
[](https://prettier.io/)
[](https://conventionalcommits.org)
> enhanced-resolve 插件,为了支持 resolve 不同优先级后缀路径
如下:
```text
foo.js
dir/
index.js
index.dev.js
index.prod.js
```
在 foo.js 中,require('./dir'), 将会根据 suffixList 的匹配顺序,依次进行命中,如 suffixList = ['.dev', '']
则 require('./dir') 则会解析成 require('./dir/index.dev.js')
经常被用在需要构建不同环境的代码的场景,如跨端代码等
## Installation
```bash
npm install suffix-resolve-plugin
# or use yarn
yarn add suffix-resolve-plugin
```
## Usage
```javascript
import { SuffixResolvePlugin } from 'suffix-resolve-plugin'
webpackConfig = {
resolve: {
plugins: [
new SuffixResolvePlugin({
suffixList: ['.dev', ''],
dir: contextPath
})
]
}
}
```
## Contributing
- Fork it!
- Create your new branch:
`git checkout -b feature-new` or `git checkout -b fix-which-bug`
- Start your magic work now
- Make sure npm test passes
- Commit your changes:
`git commit -am 'feat: some description (close #123)'` or `git commit -am 'fix: some description (fix #123)'`
- Push to the branch: `git push`
- Submit a pull request :)
## Authors
This library is written and maintained by 余聪, yucong@yuanfudao.com.
## License
MIT - [余聪](https://github.com/余聪) 🐟