All Projects → apeschar → esbuild-vue

apeschar / esbuild-vue

Licence: other
An esbuild plugin for loading and compiling Vue 2 single-file components.

Programming Languages

javascript
184084 projects - #8 most used programming language
Vue
7211 projects
HTML
75241 projects
shell
77523 projects
Makefile
30231 projects
CSS
56736 projects

Projects that are alternatives of or similar to esbuild-vue

unplugin-vue
✨ Transform Vue 3 SFC to JavaScript. Supports Vite, esbuild, Rollup and Webpack.
Stars: ✭ 38 (-11.63%)
Mutual labels:  sfc, esbuild
unconfig
A universal solution for loading configurations.
Stars: ✭ 415 (+865.12%)
Mutual labels:  esbuild
vitext
The Next.js like React framework for better User & Developer experience!
Stars: ✭ 376 (+774.42%)
Mutual labels:  esbuild
docker-node-example
An example Node / Express app that's using Docker and Docker Compose.
Stars: ✭ 122 (+183.72%)
Mutual labels:  esbuild
charpente
Seamlessly design robust 'shiny' extensions
Stars: ✭ 36 (-16.28%)
Mutual labels:  esbuild
cdk-esbuild
CDK constructs for esbuild, an extremely fast JavaScript bundler
Stars: ✭ 44 (+2.33%)
Mutual labels:  esbuild
sfc app
Service Function Chaining Application for Ryu SDN controller
Stars: ✭ 25 (-41.86%)
Mutual labels:  sfc
esbuild-css-modules-plugin
A esbuild plugin to bundle css modules into js(x)/ts(x)
Stars: ✭ 64 (+48.84%)
Mutual labels:  esbuild
bundle
An online tool to quickly bundle & minify your projects, while viewing the compressed gzip/brotli bundle size, all running locally on your browser.
Stars: ✭ 475 (+1004.65%)
Mutual labels:  esbuild
awesome-esbuild
A curated list of awesome esbuild resources
Stars: ✭ 195 (+353.49%)
Mutual labels:  esbuild
electron-esbuild
Create Electron apps using esbuild and your favorite frontend tool
Stars: ✭ 60 (+39.53%)
Mutual labels:  esbuild
fast-vite-nestjs-electron
Vite + Electron + Nestjs with esbuild, crazy fast! ⚡
Stars: ✭ 128 (+197.67%)
Mutual labels:  esbuild
hammer
Build Tool for Browser and Node Applications
Stars: ✭ 226 (+425.58%)
Mutual labels:  esbuild
esbuild-plugin-svgr
A plugin for esbuild that enables importing *.svg files as React components.
Stars: ✭ 27 (-37.21%)
Mutual labels:  esbuild
esbuild-loader-examples
esbuild-loader examples
Stars: ✭ 76 (+76.74%)
Mutual labels:  esbuild
vue-sfc-cli
🔨A powerful tool for developing vue single-file component
Stars: ✭ 137 (+218.6%)
Mutual labels:  sfc
vite-electron-esbuild-starter
⚡️The electron starter using Vite and esbuild to fast development.
Stars: ✭ 52 (+20.93%)
Mutual labels:  esbuild
tailwind-layouts
Collection of Tailwind Layouts
Stars: ✭ 53 (+23.26%)
Mutual labels:  esbuild
gulp-esbuild
gulp plugin for esbuild bundler
Stars: ✭ 39 (-9.3%)
Mutual labels:  esbuild
new-tab
⚡ A high-performance browser new tab page that gets you where you need to go faster.
Stars: ✭ 64 (+48.84%)
Mutual labels:  esbuild

esbuild-vue

This plugin lets you import Vue single-file components when bundling with esbuild. This plugin works with Vue 2.

Multiple Vue imports are built in parallel using Node.js' worker_threads via Piscina.

Installation

yarn add esbuild-vue

Getting started

In order to use esbuild plugins, you must use esbuild's JavaScript API, instead of the command line.

Let's assume you have a Component.vue, and a main.js that uses it somehow:

# Component.vue
<template>
    <h1>Hello, World!</h1>
</template>
# main.js
import Component from './Component.vue';
import Vue from 'vue';

new Vue({
    el: '#app',
    render: h => h(Component),
});

First, install the plugin, esbuild and Vue:

yarn add esbuild-vue esbuild vue

Next, create a build script build.js:

const vuePlugin = require('esbuild-vue');

require('esbuild').build({
    entryPoints: ['main.js'],
    bundle: true,
    outfile: 'out.js',
    plugins: [vuePlugin()],
    define: {
        "process.env.NODE_ENV": JSON.stringify("development"),
    },
});

Then run it:

node build.js

Now, loading index.html should display your component in its full glory.

<!-- index.html -->
<!doctype html>
<div id="app"></div>
<script src="out.js"></script>

Configuration

An object containing configuration options may be passed into the plugin constructor vuePlugin. For example:

vuePlugin({
    extractCss: true,
    workers: false,
    onReadFile: path => {
        console.error("The following dependency was used:", path);
    }
})

The following options are available:

  • extractCss: Output a separate file for inline <style> blocks in single-file components.
  • workers: The maximum amount of worker threads to use for compilation. By default this is 4 or the amount of CPUs available, whichever is least. (During my testing, larger amounts of threads don't provide a performance improvement.) Use false to disable multithreading.
  • onReadFile: Will be called with the (non-normalized) paths of every file read during the compilation process. For example, external files included using @import declarations in <style> blocks.
  • postcssPlugins: PostCSS plugins which will be used when compiling <style> blocks in components.
  • isAsync: By default, components are compiled using the synchronous (non-async) compiler. If you use async PostCSS plugins, you need to specify true here.
  • assembleOptions: Allows to provide custom normalizer, styleInjector and styleInjectorSSR implementations (upstream docs).
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].