rules
Public API surface is re-exported here.
Users should not load files under "/internal"
Macros and Functions
webpack_bundle
Runs the webpack-cli under bazel
Example usage (generated):
load("@aspect_rules_webpack//webpack:defs.bzl", "webpack_bundle")
webpack_bundle(
# A unique name for this target.
name = "",
# Label pointing to the linked node_modules target where
node_modules = None,
)
name
Required.
A unique name for this target.
node_modules
Required.
Label pointing to the linked node_modules target where
webpack is linked, e.g. //:node_modules
.
The following packages must be linked into the node_modules supplied:
webpack, webpack-cli
srcs
Optional. Default: []
Non-entry point JavaScript source files from the workspace.
You must not repeat file(s) passed to entry_point/entry_points.
args
Optional. Default: []
Command line arguments to pass to Webpack.
These argument passed on the command line before arguments that are added by the rule.
Run bazel
with --subcommands
to see what Webpack CLI command line was invoked.
See the Webpack CLI docs for a complete list of supported arguments.
deps
Optional. Default: []
Runtime dependencies which may be loaded during compilation.
chdir
Optional. Default: None
Working directory to run Webpack under.
This is needed to workaround some buggy resolvers in webpack loaders, which assume that the node_modules tree is located in a parent of the working directory rather than a parent of the script with the require statement.
Note that any relative paths in your configuration may need to be adjusted so they are relative to the new working directory.
See also: https://github.com/aspect-build/rules_js/blob/main/docs/js_binary.md#js_binary-chdir
data
Optional. Default: []
Runtime dependencies to include in binaries/tests that depend on this target.
The transitive npm dependencies, transitive sources, default outputs and runfiles of targets in the data
attribute
are added to the runfiles of this target. They should appear in the '*.runfiles' area of any executable which has
a runtime dependency on this target.
env
Optional. Default: {}
Environment variables of the action.
Subject to $(location)
and make variable expansion.
output_dir
Optional. Default: False
If True, webpack produces an output directory containing all output files.
entry_point
Optional. Default: None
The point where to start the application bundling process.
See https://webpack.js.org/concepts/entry-points/
Exactly one of entry_point
to entry_points
must be specified if output_dir
is False
.
entry_points
Optional. Default: {}
The map of entry points to bundle names.
See https://webpack.js.org/concepts/entry-points/
Exactly one of entry_point
to entry_points
must be specified if output_dir
is False
.
webpack_config
Optional. Default: None
Webpack configuration file.
See https://webpack.js.org/configuration/
configure_mode
Optional. Default: True
Configure mode
in the generated base webpack config.
mode
is set to production
if the Bazel compilation mode is opt
otherwise it is set to development
.
The configured value will be overridden if it is set in a supplied webpack_config
.
See https://bazel.build/docs/user-manual#compilation-mode for more info on how to configure the compilation mode.
configure_devtool
Optional. Default: True
Configure devtool
in the generated base webpack config.
devtool
is set to eval
if the Bazel compilation mode is fastbuild
, eval-source-map
if the Bazel
compilation mode is dbg
, otherwise it is left unset.
The configured value will be overridden if it is set in a supplied webpack_config
.
See https://bazel.build/docs/user-manual#compilation-mode for more info on how to configure the compilation mode.
use_execroot_entry_point
Optional. Default: True
Use the entry_point
script of the webpack
js_binary
that is in the execroot output tree instead of the copy that is in runfiles.
When set, runfiles are hoisted to the target platform when this is configured and included as target platform execroot inputs to the action.
Using the entry point script that is in the execroot output tree means that there will be no conflicting
runfiles node_modules
in the node_modules resolution path which can confuse npm packages such as next and
react that don't like being resolved in multiple node_modules trees. This more closely emulates the
environment that tools such as Next.js see when they are run outside of Bazel.
supports_workers
Optional. Default: False
Experimental! Use only with caution.
Allows you to enable the Bazel Worker strategy for this library.
kwargs
Optional.
Additional arguments
webpack_devserver
Runs the webpack devserver.
This is a macro that uses js_run_devserver under the hood.
Example usage (generated):
load("@aspect_rules_webpack//webpack:defs.bzl", "webpack_devserver")
webpack_devserver(
# A unique name for this target.
name = "",
# Label pointing to the linked node_modules target where
node_modules = None,
)
name
Required.
A unique name for this target.
node_modules
Required.
Label pointing to the linked node_modules target where
webpack is linked, e.g. //:node_modules
.
The following packages must be linked into the node_modules supplied:
webpack, webpack-cli, webpack-dev-server
chdir
Optional. Default: None
Working directory to run Webpack under.
This is needed to workaround some buggy resolvers in webpack loaders, which assume that the node_modules tree is located in a parent of the working directory rather than a parent of the script with the require statement.
Note that any relative paths in your configuration may need to be adjusted so they are relative to the new working directory.
See also: https://github.com/aspect-build/rules_js/blob/main/docs/js_binary.md#js_binary-chdir
env
Optional. Default: {}
Environment variables of the action.
Subject to $(location)
and make variable expansion.
entry_point
Optional. Default: None
The point where to start the application bundling process.
See https://webpack.js.org/concepts/entry-points/
Only one of entry_point
to entry_points
must be specified.
entry_points
Optional. Default: {}
The map of entry points to bundle names.
See https://webpack.js.org/concepts/entry-points/
Only one of entry_point
to entry_points
must be specified.
webpack_config
Optional. Default: None
Webpack configuration file. See https://webpack.js.org/configuration/.
configure_mode
Optional. Default: True
Configure mode
in the generated base webpack config.
mode
is set to production
if the Bazel compilation mode is opt
otherwise it is set to development
.
The configured value will be overridden if it is set in a supplied webpack_config
.
See https://bazel.build/docs/user-manual#compilation-mode for more info on how to configure the compilation mode.
configure_devtool
Optional. Default: True
Configure devtool
in the generated base webpack config.
devtool
is set to eval
if the Bazel compilation mode is fastbuild
, eval-source-map
if the Bazel
compilation mode is dbg
, otherwise it is left unset.
The configured value will be overridden if it is set in a supplied webpack_config
.
See https://bazel.build/docs/user-manual#compilation-mode for more info on how to configure the compilation mode.
args
Optional. Default: []
Additional arguments to pass to webpack.
The serve
command, the webpack config file (--config
) and the mode (--mode
) are
automatically set.
data
Optional. Default: []
Bundle and runtime dependencies of the program.
Should include the webpack_bundle
rule srcs
and deps
.
The webpack config and entry_point[s] are automatically passed to data and should not be repeated.
mode
Optional. Default: "development"
The mode to pass to --mode
.
kwargs
Optional.
Additional arguments. See js_run_devserver.