Where is the best place to insert third party CSS (bootstrap, etc …)?
In main.js using import "bootstrap/dist/css/bootstrap.min.css"; or in app.html using <import from="bootstrap/dist/css/bootstrap.min.css"></import>?
I one of the main differences is the order in which the css gets attached to the head tag of the main html file.
Also, I noticed that in the skeleton that npx makes aurelia produces the css files are automatically picked up and inserted into the build. E.g. There is a file called my-app.css and this is automatically injected into the head tag of the main html file.
That’s Aurelia 2 conventions. The my-app.css is picked up by my-app.html, you don’t have to explicitly write <import from="./my-app.css"></import> (although that also works).
If you don’t use shadow dom, css import in either js or html are doing the same thing.
If you use shadow dom, do css import in html module.
Does it also work with SCSS or other CSS preprocessors? Or can Aurelia or Webpack be configured to handle such preprocessor files instead of regular CSS files in this fashion?
The default supported are ['.css', '.scss', '.sass', '.less', '.styl'], and our @aurelia/webpack-loader and @aurelia/plugin-gulp also allows additional option to add unknown css file extensions (not well documented yet).
Some dessert
In this same file, you may notice the template file (defaultTemplateExtensions) doesn’t have to be my-app.html. You can have my-app.md or my-app.haml as long as you config webpack to process them. You can even mix all of those file extensions in one project. Have a look of the webpack config in this demo. GitHub - 3cp/au2-webpack-md-demo: markdown-loader before au2 conventions
Our approach is different from other all-in-one solutions, such as Vue’s Single File Component support which handles all scss/less/postcss/ts/babel in Vue’s SFC component compiler.
In contrast, we make tools to take much less responsibility, but cooperate with existing tools. Users are free to setup their own css pipeline, such as preprocess and postcss.