Webpack
The Aurelia CLI offers full support for Webpack as a bundler, suitable for both ESNext and TypeScript applications.
PLATFORM.moduleName
When referencing modules by string in a Webpack-configured Aurelia application, wrap the module names using PLATFORM.moduleName
. This informs Webpack about Aurelia's dynamic loading behavior.
Example:
Hint: The aurelia-webpack-plugin
processes PLATFORM.moduleName
, bridging Webpack with Aurelia's dynamic behavior.
Running the Application
To run your Aurelia application with Webpack:
Common Flags:
--hmr
: Enables Hot Module Reload.--analyze
: Opens the Webpack Bundle Analyzer.
Configuration:
Default settings for au run
are located in the platform
section of aurelia.json
:
Adjust settings like hmr
, open
, and port
as needed.
Simplified Webpack
From Aurelia CLI v1.1.0 onwards, Webpack usage has been simplified:
Decoupled Bundler: Webpack operates independently from the CLI's task files.
Commands:
au run
maps tonpm start
.au build
maps tonpm run build:dev
.
Environment Configuration:
Environment files are located in the config/
folder, managed by the app-settings-loader
Webpack plugin.
Deploying Your App
To prepare your application for deployment:
Create a Production Build:
Deployment Output:
Non-ASP.NET Core: Contents reside in the
dist
folder. Copy this to your web server.
Build Options
Webpack configurations are exported as functions based on parameters:
These parameters are influenced by the build.options
in aurelia.json
:
Production Flag: Determined by the
--env
flag (prod
for production builds).
Installing 3rd Party Dependencies
Webpack intelligently bundles 3rd party dependencies. To install a new dependency:
Unit Testing
Depending on your setup during au new
, you may have one of the following test runners:
Jest:
Karma:
Protractor:
Ensure
nps
is installed globally:
ASP.NET Core
When integrating with ASP.NET Core:
Set Environment Variable:
Configure Project:
Use Visual Studio to create the ASP.NET Core project.
Integrate Aurelia using
au new --here
within the project directory.
Hint: Prevent Visual Studio from compiling TypeScript by adding <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
to your .xproj
file.
Last updated
Was this helpful?