@lukalabs/esbuild-inject-plugin

1.1.0 • Public • Published

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

  1. Replace build and dev scripts in your package.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",
}
  1. Add esbuild-plugins.js to project’s root folder (or provide config path via ESBUILD_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];
}

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @lukalabs/esbuild-inject-plugin

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

4.45 kB

Total Files

6

Last publish

Collaborators

  • alexkuz