3.0.5 • Published 1 year ago
alias-reuse v3.0.5
⚙️ Alias reuse
Reuse custom or existing aliases from one configuration in others.
.
Install
npm i alias-reuse --save-dev.
Usage
Import
Import aliases from existing configuration. The library will automatically detect the configuration source type.
Supported configuration sources:
tsconfigwebpack/viteobject
reuse().from(pathToConfig: string);... and also from custom object.
reuse().from(config: Record<string, string>);Configure
Set custom root directory.
reuse().from(...).at(pathToRoot: string);Export
Export of aliases in a required configuration target.
Supported configuration targets:
tsconfigwebpack/vitejestobject
reuse().from(...).for(target: string);.
Examples
Example for Webpack
const { reuse } = require('alias-reuse');
const tsconfigPath = path.join(__dirname, 'tsconfig.json');
module.exports = {
resolve: {
alias: reuse()
.from(tsconfigPath) // Import aliases from tsconfig.json
.for("webpack"), // And convert to webpack format
},
// ...
};Example for TSConfig
const { reuse } = require('alias-reuse');
const configPath = path.join(__dirname, 'configs/aliases.json');
module.exports = {
compilerOptions: {
paths: reuse()
.from(configPath) // Import aliases from custom config
.for("tsconfig"), // And convert to tsconfig format
},
// ...
};Example with custom root directory
const { reuse } = require('alias-reuse');
const rootPath = path.join(__dirname, 'root');
const configPath = path.join(__dirname, 'configs/aliases.json');
module.exports = {
resolve: {
alias: reuse()
.from(configPath) // Import aliases from custom config
.at(rootPath) // Set root directory
.for("vite"), // And convert to vite format
},
// ...
};3.0.3
1 year ago
3.0.2
1 year ago
3.0.1
1 year ago
3.0.5
1 year ago
3.0.0
1 year ago
2.0.2
1 year ago
2.0.1
2 years ago
2.0.0
3 years ago
1.0.11
3 years ago
1.0.10
3 years ago
1.0.9
3 years ago
1.0.8
4 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago