esbuild-inject-plugin
This plugin patches build
function of esbuild to include additional plugins provided via config.
Intended to be used in Remix projects, which currently doesn’t support custom esbuild plugins.
Install
npm install -D @lukalabs/esbuild-inject-plugin
# or
yarn add -D @lukalabs/esbuild-inject-plugin
Usage with Remix
- Replace
build
anddev
scripts in yourpackage.json
(you can also use binode to make it work on Windows)
package.json
"scripts": {
- "build": "remix build",
- "dev": "remix dev",
+ "build": "node --require @lukalabs/esbuild-inject-plugin -- ./node_modules/.bin/remix build",
+ "dev": "node --require @lukalabs/esbuild-inject-plugin -- ./node_modules/.bin/remix dev",
}
- Add
esbuild-plugins.js
to project’s root folder (or provide config path viaESBUILD_INJECT_PLUGIN_CONFIG
environment variable) (@lukalabs/esbuild-styled-components used here as an example)
esbuild-plugins.js
const styledComponentsPlugin = require('@lukalabs/esbuild-styled-components').default;
exports.plugins = function(plugins) {
return [styledComponentsPlugin(), ...plugins];
}