Aurelia-CLI
First of all, webpack is highly recommended. The amount of fiddling with the new CLI version 0.33.1 is just annoying.
Not convinced? Keep reading and compare to webpack installation procedure.
Scaffolding the app
Make sure you have at least version 0.32.0 of Aurelia-CLI installed.
Note: 0.33.1 requires some additional configuration. Make sure you follow the instructions!
$ au newChoose Aurelia options as you see fit. In the last step, choose to install all dependencies.
Getting the plugin
In your project install the following via CLI (execution order matters!):
$ au install jquery
$ au install tslib
$ au install materialize-amd
$ au install aurelia-materialize-bridgeThe materialize-amd is an AMD compatible build of Materialize-CSS. Installing it with au new also copies CSS and font files to the styles folder.
Note: Due to a change in Materialize's loading order (probably this commit), version v0.100.2 won't work with Aurelia CLI RequireJS. Therefore, the maximum (and in fact the only) AMD build is v0.100.1
If you need an AMD build of an earlier version create and issue in the repository
Configure your app
For Material Design icons include this in your
index.htmlhead section:<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">Add this to
main.jsin yoursrcfolder:aurelia.use.plugin('aurelia-materialize-bridge', b => b.useAll().preventWavesAttach());Note: The above shows how to use all available controls at once. If you choose to pick which you'd like to use, you can
usesingle components like this:.plugin('aurelia-materialize-bridge', bridge => { bridge .useButton() .useCollapsible() .useModal() .useTabs() .useWaves().preventWavesAttach(); });At the end of this page is a full list of currently available options. Important:
preventWavesAttachis only needed with CLI to prevent dimmed buttons. See this issue for details.Add this to your
index.html<link rel="stylesheet" href="styles/css/materialize.min.css">Note: The CLI cannot bundle fonts like webpack, plus
materialize.cssfile references the fonts by relative paths (eg "../fonts/roboto/Roboto.ttf").If you
requirematerialize.cssfrom HTML the relative path is interpreted to be relative to the path specified inaurelia.json. While in reality, fonts still reside innode_modules, requirejs looks for fonts inmaterialize-amd/fonts/roboto(from evaluation ofmaterialize-amd/css/../fonts/roboto).You can still use the following in
app.html<require from="materialize-amd/css/materialize.css"></require>but in this case you will have to manually copy fonts to
materialize-amdfolder in the root of your project.When using version
0.33.1of the CLI add "node_modules/jquery/dist/jquery.js" to theprependsection of thevendor-bundle.jsconfiguration in theaurelia.jsonfile. Without it your project won't run, complaining about missing$declaration and weirdly loading modules fromnode_modulesdirectly. Removejqueryfromdependenciessection.When using version
0.33.1of the CLI add "node_modules/materialize-amd/dist/js/materialize.amd.js" to the end ofprependsection of thevendor-bundle.jsconfiguration in theaurelia.jsonfile - afterjqueryandrequire. Also removematerialize-amdconfiguration fromdependenciessection.Note: This is necessary because dependencies loading order is broken again in CLI (duh!). If
materialize-amdis left in there it will add functions to the prependedjquerybut the bridge will try to usejqueryfrom dependencies.
You are done!
It is now possible to drop some custom-elements into your DOM. See the other pages on this website for detailed information on how to do this.
Now you might want to do our app developers tutorial, based on Aurelia Skeleton navigation.
As described above, here is a full list of available options:
aurelia.use.plugin('aurelia-materialize-bridge', bridge => {
bridge
.useAutoComplete()
.useBadge()
.useBreadcrumbs()
.useBox()
.useButton()
.useCard()
.useCarousel()
.useCharacterCounter()
.useCheckbox()
.useChip()
.useCollapsible()
.useCollection()
.useColors()
.useDatePicker()
.useDropdown()
.useFab()
.useFile()
.useFooter()
.useInput()
.useModal()
.useNavbar()
.usePagination()
.useParallax()
.useProgress()
.usePushpin()
.useRadio()
.useRange()
.useScrollfire()
.useScrollSpy()
.useSelect()
.useSidenav()
.useSlider()
.useSwitch()
.useTabs()
.useTooltip()
.useTransitions()
.useWaves()
.useWell();
});Last updated