Aurelia - Adding Font-Awesome to a webpack asp.net aurelia project - aurelia

I'm using ASP.NET Core 2, latest Aurelia/Aurelia CLI and I have been looking to install Font-Awesome however this does not appear to be that straightforward.
I see this SO question however I do not have an aurelia.json file. This appears to also be a requirement in this SO question as well.
It appears to not be as simple as just adding it via npm.
Given I have an ASP.NET 2 project, Webpack and no aurelia.json file (I do have a package.json if thats what they are referring to) whats the process of including Font Awesome in this regard?

OK, so this turned out to be such a chore to figure out, but at the end of the day, the answer was actually a simple two liner.
I looked at a number of solutions, tried a number of different things, yet time and time again I kept getting what was apparently web-pack ignoring my rules, and just trying to load things as it pleases.
After looking at a number of other stack overflow posts and spending a good few hours trying different bit's in my webpack.config.js file (and the vendor one that gets produced by the dotnet core 2 template), I eventually figured out the following:
1) npm install the version of font awesome you wish to use.
2) In your app.html file, make sure it looks as follows:
<template>
<require from="./app.css"></require>
<require from="font-awesome/css/font-awesome.css"></require>
... rest of your html here ...
</template>
3) Edit your webpack.config.js file so that your rules section looks as follows (This is the most important part)
module: {
rules: [
{ test: /\.ts$/i, include: /ClientApp/, use: 'ts-loader?silent=true' },
{ test: /\.html$/i, use: 'html-loader' },
{ test: /\.css$/i, use: isDevBuild ? 'css-loader' : 'css-loader?minimize' },
{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' },
{ test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/, loader: 'file-loader' }
]
},
If you have other rules you need to keep, then you'll need to merge them and make sure you have no duplicates, or anything like that.
This is a similar answers to others that are on here, but as Iv'e found the other ones just don't seem to work with the dotnet core 2 spa template, where as this one does.
I suspect that as others have said it is something to do with the reg-ex.
One more thing to note.
If you look in webpack.vendor.config.js , you'll see that there is already a rule in there to handle font files, but that seems to get ignored for anything but a simple non versioned statically included file to override the general font, so I left mine in.
Altering the one that's present just doesn't seem to work either.

font-awesome installation has changed a bit with new versions. Moreover aurelia-cli has changed and improved a lot in past few months.
Above answers might not work anymore. Please check my answer here for webpack based aurelia-cli generated project.

Related

How to use this NPM package: svgo-unique-id?

I use a package called SVGO to minify svg files like many others. Unfortunately when it minifies it generates generic id's that cause issues when you inline them on the same page as they use the same id.
In comes the plugin in question, it's supposed to fix this issue by prefixing the id's so they're unique and wont overwrite each other.
Problem is, I have no idea how it works. It says
Usage
new SVGO({
plugins: [{
uniqueID: require('svgo-unique-id'),
}]
})
Now I don't know if I'm supposed to add this anywhere, if it's automatically added, if I need to create a new file for this or anything.
So my question really is, how do I go about using this. I think it should be straight forward but I've never used a plugin for a package before so I don't know anything about how it works.
Any pointers are much appreciated.

Correct version of Node/ECMA for linting

I'm using Prettier in VSCode, but it appears to be flagging mistakes that I think are ok.
Specifically, if I test a variable like:
if (myObject?.property1?.property2) {
....
}
(Not sure of the correct name for using questions marks like this) then it flags the question marks as invalid.
I can see there is an ecmaVersion setting in .prettierrc but this doesn't seem to do anything, and anyway, as I understand it, Node versions don't exactly follow ECMA versions anyway.
What can I do to make Prettier correctly lint my code?

LazyLoad Module in Angular 1.5 component Meteor

I am dying here on lazily loading modules into angular-meteor 1.5.
So the Meteor Version is 1.4.2.3, meaning with ES2015, import, ui-router etc.
So far I've tried ocLazyLoad, angularAMD has a completely different syntax (with define(function()...) which I don't know how to "merge" with the Boilerplate App of Urigo's angular-meteor.
So in ocLazyLoad, I went by this https://github.com/alo/oclazyload-uirouter-component-routing-tests github example, since it is the only one I've found that has the ng 1.5 components and submodules instead of just lazily adding controllers to the main apps module.
When I try to implement this, ocLazyLoad logs that the js-file is loaded, but in the Sources-tab instead of the actual file, the js-file contains the whole meteor app.
Any idea on why that is or whether angularAMD works with angular-meteor or in general, how to make lazyLoading modules work?
It's not as natural as it should be because meteor doesn't support lazy loading yet. But here is a working solution:
If your are trying to use lazy loading on routes like this:
{ path: "myPath", loadChildren: "app/myModule/myModule.module#MyModule"}
You should use instead a callback to get the module using ES5 callbacks.
{path: "myPath", loadChildren: ()=> require('./myModule/myModule.module')["MyModule"] }
Hopefully will work for you as well. :)
Question answered on my post

LessCss on Java, what version is being used?

I just sent this to Alexis Sellier <self#cloudhead.net> but it bounced back, prompting me to seek answers here:
Hi Alexis,
First and foremost, thanks for a great Java support for the lesscss library!
I am and have been for a while on version 1.7.0.1.1.
I was attempting to use the extend feature which worked when used as:
.button-a {
&:extend(.button-base);
.rounded-corners-top(7px);
}
but not when used as
.button-a:extend(.button-base) {
.rounded-corners-top(7px);
}
further more, the first case does not work if button-base well looks like this:
.button-base {
...
&:hover {
background-color: white;
color: #ff3c1f;
}
}
The hover stuff never gets active from extended contexts. Does this work in the JS version?
I tried to peek into the java package and it seems you have merged
what I believe to be the JS library with some other Rhino JS code,
making it hard to upgdrade to the latest JS version.
It is not clear from the Java library what version is being used either.
I have myself written another js library and successfully used Rhino,
EnvJS and my JS library, and I choose to approach it a bit
differently, namely that the JS can be supplied separately, as an
argument to my java class which takes care of merging it all.
Is that something you think is possible? If not, how up to date with
the JS code is the current Java version?
What limitations do you see in going the approach I've mentioned above.

Documenting Node.js projects [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I'm currently using JSDoc Toolkit to document my code, but it doesn't quite fit - namely, it seem to struggle with describing namespaces properly. Say you have two simple classes in each their files:
lib/database/foo.js:
/** #class */
function Foo(...) {...}
/** #function ... */
Foo.prototype.init(..., cb) { return cb(null, ...); };
module.exports = foo;
And then something inherited lib/database/bar.js:
var Foo = require('./foo');
/**
* #class
* #augments Foo
*/
function Bar(....) {...}
util.inherits(Bar, Foo);
Bar.prototype.moreInit(..., cb) { return cb(null, ...); };
In the generated documentation, this is output simply as Foo and Bar, without the leading database (or lib.database), which are quite necessary when you don't have everything in a global scope.
I've tried throwing #namespace database and #name database.Foo at it, but it doesn't turn out nice.
Any ideas for making JSDoc output something more suitable, or some entirely different tool that works better with Node.js? (I looked briefly at Natural Docs, JSDuck and breezed over quite a few others that looked quite obsolete...)
JSDoc is a port of JavaDoc. So basically the documentation assumes classical OOP and that's not suited to JavaScript.
Personally I would recommend using docco to annotate your source code. Examples of it can be found for underscore, backbone, docco.
A good alternative to docco is groc
As for an actual API documentation, I personally find auto generated documentation from comments just does not work for JavaScript and recommend you hand-write your API documentation.
Examples would be underscore API, Express API, nodejs API, socket.io docs
Similar StackOverFlow questions
Generating Javascript documentation
YUIDoc is a Node.js application that generates API documentation from comments in source, using a syntax similar to tools like Javadoc and Doxygen. YUIDoc provides:
Live previews. YUIDoc includes a standalone doc server, making it trivial to preview your docs as you write.
Modern markup. YUIDoc's generated documentation is an attractive, functional web application with real URLs and graceful fallbacks for spiders and other agents that can't run JavaScript.
Wide language support. YUIDoc was originally designed for the YUI project, but it is not tied to any particular library or programming language. You can use it with any language that supports /* */ comment blocks.
NOTE: Dox no longer outputs HTML, but a blob of JSON describing the parsed code. This means the code below doesn't work terribly well any more...
We ended up using Dox for now. It is a lot like docco, that Raynos mentions, but thows all of it in one bit HTML-file for output.
We hacked this into our makefiles:
JS_FILES := $(shell find lib/ -type f -name \*.js | grep -v 3rdparty)
#Add node_modules/*/bin/ to path:
#Ugly 'subst' hack: Check the Make Manual section 8.1 - Function Call Syntax
NPM_BINS:=$(subst bin node,bin:node,$(shell find node_modules/ -name bin -type d))
ifneq ($(NPM_BINS),)
PATH:=${NPM_BINS}:${PATH}
endif
.PHONY: doc lint test
doc: doc/index.html
doc/index.html: $(JS_FILES)
#mkdir -p doc
dox --title "Project Name" $^ > $#
It is not the prettiest or most efficient documentation ever made (and dox has quite a few minor bugs) - but I find it work rather well, at least for minor projects.
Sorry, I was not on StackExchange a year ago, but I believe the answer to your original question is to use the #memberOf tag:
/** #namespace */
database = {};
/**
* #class
* #memberOf database
*/
function Foo() { ... };
http://code.google.com/p/jsdoc-toolkit/wiki/TagMemberOf
This tag may or may not have existed when you asked your question.
Found a really nice solution for the problem: doxx.
It uses dox as mentioned above and converts this to nice HTML afterwards. Has a nice usage and worked great for me.
https://github.com/FGRibreau/doxx
I work with JSDoc and is very efficient, in addition to easy, but when projects have many alternate libraries are quite complicated development. I found Groc a very good tool based on Docco and works with other languages like: Python, Ruby, C + +, among others...
Furthermore Groc working with Markdown in GitHub which can be much more efficient when working with git as version control. Further helps assemble pages for publishing on GitHub.
You can also use the task manager GruntJS through grunt-groc example:
Install package:
npm install grunt-groc --save-dev
configure in your task file:
grunt.loadNpmTasks('grunt-groc');
And the config task:
// Project configuration.
grunt.initConfig({
groc: {
coffeescript: [
"coffee/*.coffee", "README.md"
],
options: {
"out": "doc/"
}
}
});
For run task:
grunt.registerTask('doc', ['groc'])