Auto minify output Javascript file on elm make - elm

What's the best way that when you run
elm make Main.elm --output elm.js
The output Javascript file is already minified?

The official guide has an example if you're using UglifyJS https://guide.elm-lang.org/optimization/asset_size.html. The tldr is to create a script (such as a bash file on Mac or Linux) that looks like
#!/bin/bash
# compile
elm make src/Main.elm --optimize --output=elm.js
# minify
uglifyjs elm.js --compress 'pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe' | uglifyjs --mangle --output elm.min.js
This is the approach I use in most of my projects that are Elm only or even light on JS. I do however use Terser instead of UglifyJS as it has better support for modern JS and accepts the same arguments is I can literally just replace uglifyjs with terser in the above script.

The elm make command cannot do this for you. However, you can simply run a minifier on the output.
Check out the optimization hint for examples:
https://github.com/elm/compiler/blob/master/hints/optimize.md
Also don't forget to add --optimize to elm make when building for production.

Related

How to make each Vue build include a version accessible in Vue app?

In Vue, I'd like to be able to get the current build version. Preferably, it would be in YYYY-MM-DD-HH-MM format (the build time), rather than a random hash (which would be ok too).
Here's how someone did this
https://medium.com/#howitson/passing-generated-build-numbers-to-vue-app-f301e6b11877
Another idea:
have a bash script which updates .env file with a line VUE_APP_BUILD_VERSION=... (is there any utility for this?)
and then run npm run build
Any suggestions for simpler ways? Maybe get the .js file path and use that? /js/app.5e716dd8.js
You can use npm version patch in your build script, and get the version number from package.json.

Is the exact lua binary able to be specified in the luarocks compilation options?

Right now I have to create a symlink to the lua runtime I'm using:
ln -s $PREFIX/bin/lua-tarantool $PREFIX/bin/tarantool
Then I have to use --lua-suffix="-tarantool" for the ./configure options.
Is there a way to specify the exact name of the binary without resorting to symbolic links? For example: --with-lua-bin=$PREFIX/bin/tarantool
I checked the options and there doesn't seem to be anything like that: https://github.com/keplerproject/luarocks/wiki/Installation-instructions-for-Unix#Customizing_your_settings
You can set the following in your ~/.luarocks/config.lua file:
lua_interpreter = "/some_dir/bin/tarantool"
variables = {
LUA = "/some_dir/bin/tarantool"
}
You might need to tweak the first line of the luarocks script, though (or run it with tarantool /path/to/luarocks).
But you can also ask yourself: do you need to run LuaRocks with tarantool? It should be possible to install plain Lua, LuaRocks and Tarantool, and configure LuaRocks to use plain Lua, but to install modules to the Tarantool path.

Sass Intellij File Watcher Output path Ubuntu

I am trying to compile a .scss file in sass directory to a sibling css directory. However, I am not able to. I dint find enough documentation on the file watcher plugin as well.
Currently, it is compiling into the sass directory. And I need to compile into css directory.
I am able to compile it manually using
sass --watch sass/file.scss:css/file.css
How do I do it using Intellij File Watcher plugin?
I tried using the macros but I dont think I understand macros much, because I either get directory not found or .scss file not found. I am aware that I have to change the argument input in some way, but
--watch sass/file.scss:css/file.scss
dint work.
Pl help.
I am guessing you may have figured this out by now. But this may be helpful for future searches.
You don't need to add sass --watch to the arguments because that happens implicitly via the Intellij watcher.
But lets say you have a directory structure like so...
-C
-path
-to
-css
styles.css
-sass
styles.scss
You would do something like this in Arguments:
--no-cache --update C:\path\to\css\sass:C:\path\to\css
And then set your working directory to C:\path\to\css\sass
Example:

Apidocjs document creation issue, warning : plugin param parser not found and missing comma issue

I tried to create API documentation using apidocjs and i got issues while compiling project for creating apidoc using apidoc.json on project folder.
Code here :
~$ apidoc -i ./ -o apidoc/
And result
warning: parser plugin 'param' not found.
error: Error: Can not read: apidoc.json, please check the format (e.g. missing comma).
Please anyone help me to fix this issue
Tags related to apidocjs.com
Removing the apidoc destination folder as #Prasanth suggests will destroy your history if you are using the #apiVersion feature. The only way you could rebuild it is to go through and checkout each version, then run the apidoc. So, if you want to use versioning. This is not your answer.
You may have syntax issues or some other configuration issue.
In my case, since updating I had some functions documented in javadoc style with #param... this used to be ignored but now throws the warning.
~$ apidoc -i ./ -e apidoc/ -o apidoc/
when api document generates, it generates main.js file with #param.
and as that #param will also be checked next time of generation, you can just skip that output directory and all are good to go.
Issue is fixed for me as well, This error comes from the generated docs/main.js.
Usually we should parse only necessary files, to generate this apiDoc.
I used -f .php in my command, like apidoc -f .php -i ./ -o ./. This is working like a miracle.
I had the same proble. I'm using custom template and template folder was in the same location as my *.js files which are parsed including main.js template file. -e option did not worked for me so I moved template folder to other location and everything works fine.
I had the same issue in rebar using erlang and what I did was in the project root folder:
rm -rf doc/
then I run again apidoc
info: Done
For fix this bug, you can try to save package.json and apidoc.json without UTF-BOM symbol.
Some versions, parts or dependecies of apidoc use code similar with this
JSON.parse(fs.readFileSync(file, 'utf-8')) // throw "Uncaught SyntaxError: Unexpected token in JSON at position 0"

Automate Sass execution thru terminal (os x) via script

I started using Haml/Sass thru Rubygems recently, and I'm really liking it (although that doesn't have much to do with my question)...
I would like to create a simple script I can throw in the root directory of each of my projects that will launch terminal, cd to my CSS folder, and run sass. so essentially a script that:
cd ~/path_to_here/css/
sass --watch style.scss:style.css --style compact
I'm not really sure the best way to go about this, anything involving the command line is always slightly out of my comfort zone. Many thanks.
This script won't open the Terminal for you; but it will give you a shortcut to do the repetitive task of changing to the project directory and calling the compass watch command. (I highly recommend you to use Compass which is a SASS compilation of Tools to make your life easier.)
Put this inside your ~/.profile file and restart your terminal:
alias watch=compass_watch_project
function compass_watch_project() {
cd ~/Dev/ruby/$1;
compass watch
}
Remember to change the ~/Dev/ruby/ to your directory path.
After this you can easily do a watch myProject.
Hope it helps.
Consider using Compass for managing the building of your Sass files: It has a script for watching changes in all your project files and setting up all the output parameters.
You can create a simple text file with the extension .command which will make it a double-clickable script in OSX:
#!/bin/bash
compass watch
You could write a applescript that would launch terminal, and call a shell script.
Applescript
tell application "Terminal"
do script "pushd /blash/sassstup.sh"
end tell
shell script:
cd cssfolder
/bin/sass --watch style.scss:style.css --style compact