Rax official engineering tools use @alib/build-scripts . @alib/build-scripts is based on webpack, supports various scenarios through the plugin system, and provides flexible webpack configuration capabilities based on webpack-chain. Users can realize engineering requirements by combining various plugins.
Install the latest version and initialize the project
$ npm init rax my-app$ npm install @alib/build-scripts --save-devConfiguration build.json
{
"plugins": [
["build-plugin-rax-app", { "targets": ["web"]}]
]
}@alib/build-scripts Itself will not perform any operations, but according plugins configured in build.json to execute engineering commands, for example, an ordinary webapp project configuration is as follows
The plugin needs to export a function. The function will receive two parameters. The first is the pluginAPI provided by build scripts, and the second is the user-defined parameter passed to the plugin
module.exports = (pluginAPI, options) => {
const {
context,
log,
onHook
} = pluginAPI;
};context: environment information (command、commandArgs、rootDir、userConfig、pkg)onGetWebpackConfig: You can modify the weback configuration in the form of weback chainonHook: Listening for command runtime events withonHooklog: use npmlogregisterTask: register webpack taskregisterUserConfig: Register the top-level configuration field in build.json for user field verificationregisterCliOption: cli configsetValue&getValueUsed to register variables in context for communication between plug-ins
start
before.start.loadBefore getting the webpack configurationbefore.start.runBefore webpack executionafter.start.compileAfter compilation, every recompilation will be executedbefore.start.devServerAfter the middleware is loaded, before the webpack dev server is startedafter.start.devServerAfter the webpack dev server is started
build
before.build.loadBefore getting the webpack configurationbefore.build.runBefore webpack executionafter.build.compileEnd of build
Build Single-page application (SPA)
Build Multi-page application (MPA)
Build universal component or universal API library
Build Progressive web application
Build Server-side rendering application (SSR)