How Do You Run Webpack from a JavaScript file?

Code Whisperer

As we all know, you can run Webpack from the command line using the CLI by running,

webpack

Which reads the file webpack.config.js and compiles your files accordingly.

Is it possible to do this same thing from within a file? In other words, is it possible to run Webpack without using the CLI?

Paul

Yes.

https://webpack.js.org/api/node/

const webpack = require("webpack");

webpack({
  // Configuration Object
}, (err, stats) => {
  if (err || stats.hasErrors()) {
    // Handle errors here
  }
  // Done processing
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I run webpack from SBT

How do you run an .exe file on Docker?

How do you run Javascript in Django?

Python Scrapy: How do you run your spider from a seperate file?

How do you run code on a remote postgres database on heroku from .bat file

How do you automatically run a .bat file from a flashdrive with cmd programming?

How do you automatically download a file in javascript?

How do you abstract out an HTML template literal from a JavaScript file, to a separate file, and import it back?

How do you run a js file using npm scripts?

How do you run a setup.py file properly?

How do you run a command for each line of a file?

How do you run a single test/spec file in RSpec?

How do you run multiple karate feature file in a gatling simulation?

How do you run a standalone ijs j file on Linux?

How do you assemble, link and run a .s file in linux?

How do you run code for the duration of a sound file? - Swift

How do you run JavaScript script through the Terminal?

How do you run two different functions in javascript

How do you run javascript with only a CSS class?

How do you run a JavaScript function on a specific Wordpress page?

How do you produce a .d.ts "typings" definition file from an existing JavaScript library?

How do you run tests from the command line?

How do you run cpack from visual studio?

How do you run multiple programs in parallel from a bash script?

How do you run batch files from Powershell?

How do you set up gsutil to be run from the command line

How do you run functions and variables from shell script into docker?

How do you run micronaut from gradle with local properties

How do you run pytest or flask8 from powershell?