Socket
Socket
Sign inDemoInstall

@nuxt/builder

Package Overview
Dependencies
Maintainers
6
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxt/builder


Version published
Weekly downloads
194K
decreased by-2.64%
Maintainers
6
Weekly downloads
 
Created

What is @nuxt/builder?

@nuxt/builder is a core package of the Nuxt.js framework that is responsible for building and bundling the application. It handles the compilation of Vue components, the generation of server and client bundles, and the optimization of assets. This package is essential for the development and production build processes in Nuxt.js applications.

What are @nuxt/builder's main functionalities?

Building the Application

This feature allows you to programmatically build your Nuxt.js application. The code sample demonstrates how to load the Nuxt configuration and use the Builder class to compile and bundle the application.

const { Builder } = require('@nuxt/builder');
const { loadNuxt } = require('nuxt');

async function build() {
  const nuxt = await loadNuxt({ for: 'build' });
  const builder = new Builder(nuxt);
  await builder.build();
}

build();

Generating Static Assets

This feature allows you to generate static assets for your Nuxt.js application. The code sample shows how to use the Builder and Generator classes to create a static version of the application, which can be deployed to static hosting services.

const { Builder, Generator } = require('@nuxt/builder');
const { loadNuxt } = require('nuxt');

async function generate() {
  const nuxt = await loadNuxt({ for: 'build' });
  const builder = new Builder(nuxt);
  const generator = new Generator(nuxt, builder);
  await generator.generate({ build: true });
}

generate();

Customizing the Build Process

This feature allows you to customize the build process by hooking into various build lifecycle events. The code sample demonstrates how to add hooks for the 'build:before' and 'build:done' events to execute custom logic at different stages of the build process.

const { Builder } = require('@nuxt/builder');
const { loadNuxt } = require('nuxt');

async function customBuild() {
  const nuxt = await loadNuxt({ for: 'build' });
  nuxt.hook('build:before', () => {
    console.log('Before build');
  });
  nuxt.hook('build:done', () => {
    console.log('Build done');
  });
  const builder = new Builder(nuxt);
  await builder.build();
}

customBuild();

Other packages similar to @nuxt/builder

FAQs

Package last updated on 24 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc