Skip to content

webpack

The webpack plugin gives every package with a webpack config a build task, and a dev task when the config has a dev server.

Terminal window
axle add webpack

This writes it into the root axle.toml:

[plugins.webpack]
source = "npm:@axle-rs/[email protected]"
hash = "sha256-…"

A package or project with a webpack.config file, .ts, .mts, .cts, .js, .mjs or .cjs, in its folder gets:

Task Command Settings
build webpack build outputs the output folder
dev webpack serve when the config has a devServer; persistent

Each command runs through the repository’s package manager, such as pnpm exec webpack build, so it uses the version the package installs.

The output folder is output.path in the config, read without running it, and dist by default. Most configs set it with path.resolve(__dirname, …), which can’t be read, so the plugin leaves outputs out and Axle finds the outputs the build writes itself.

A package’s own script wins. When its package.json has a script with a task’s name that runs something else, such as "build": "webpack --mode production", the plugin leaves that task alone and Axle runs the script. A script that only runs webpack the way the plugin would, webpack build, webpack, webpack serve or webpack dev, is replaced by the plugin’s task, which runs the same command and adds its settings. The repository’s axle.toml changes a task as it would any other, and wins over the plugin.

Setting Default Meaning
build "build" the name of the build task, or false to leave it out
dev "dev" the name of the dev server task, or false
[plugins.webpack]
source = "npm:@axle-rs/[email protected]"
hash = "sha256-…"
build = "bundle"

The plugin’s answers are kept until a webpack.config.*, a package.json, pnpm-workspace.yaml or a lockfile changes.