README
esbuild-plugin-at-src-alias
esbuild plugin for @ alias to ./src.
Forked from & inspired by https://github.com/igoradamenko/esbuild-plugin-alias.
Rationale
Vue cli generated projects works with @ pointing to ./src. Quick and dirty solution to make them work in esbuild.
Installation
npm install --save-dev esbuild-plugin-at-src-alias
Usage
Define plugin in the plugins
section of esbuild config like this:
const esbuild = require('esbuild');
const alias = require('esbuild-plugin-at-src-alias');
esbuild.build({
// ...
plugins: [
alias(),
],
})
Example
Having this input file:
// src/app.js
import settings from '@/config/settings';
console.log(settings);
And esbuild config like this:
// config/build.js
const path = require('path');
const esbuild = require('esbuild');
const alias = require('esbuild-plugin-at-src-alias');
esbuild.build({
entryPoints: ['in.js'],
bundle: true,
outfile: 'out.js',
plugins: [
alias(),
],
}).catch(err => process.exit(1));
You will get src/config/settings.js
loaded.
Check test/ for more detailed example.