Browserify exclude does not seem to work - browserify

I am trying to exclude JQuery from my build file:
browserify --exclude jquery -g uglifyify -e src/main.js -t partialify -t uglifyify > dist/bundle.min.js
Only JQuery is still in the bundle.min.js? Am I doing something wrong?
https://github.com/substack/browserify-handbook#ignoring-and-excluding

Have you tried the following?
browserify src/main.js --exclude jquery -g uglifyify -t partialify -t uglifyify > dist/bundle.min.js
the usage is as follows, i.e. options come after entry files:
Usage: browserify [entry files] {OPTIONS}

Related

sass --watch : could not find option named "watch"

Simple one, but could not find the answer anywhere online! Installed sass globally (npm install -g sass) on my Mac.
This works as expected:
sass style.scss style.css
Then I try:
sass --watch style.scss:style.css
And get:
Could not find an option named "watch".
Usage: sass <input> [output]
--[no-]stdin Read the stylesheet from stdin.
--[no-]indented Use the indented syntax for input from stdin.
-I, --load-path=<PATH> A path to use when resolving imports.
May be passed multiple times.
-s, --style=<NAME> Output style.
[expanded (default), compressed]
-c, --[no-]color Whether to emit terminal colors.
-q, --[no-]quiet Don't print warnings.
--[no-]trace Print full Dart stack traces for exceptions.
-h, --help Print this usage information.
--version Print the version of Dart Sass.
What am I missing??
Thanks!!
First create the SASS's folder, and in there create your SASS's file. Example:
sass/styles.sass
In your project root folder, open the console and type the command:
sass --watch sass/styles.sass:css/styles.css
This command will create your CSS's folder and CSS's file. In addition to compiling your .sass content for your .css.
In the end, I gave up on sass as tried above, and went for a solution with webpack.
Another option I tried which worked was to use node-sass.
I solved running this command on your terminal
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
i hope that help

Using CMake's fixup_bundle for bundling linux-only application

We developing some CV application, based of OpenCV, Boost, LibVLC and Caffe. Some of our customers want to deploy it on outdated(or unpopular) Linux distributions, so we must bundle all it's dependencies(and some vlc plugins), most of them can be found in any actual distro, but we have custom build of libcaffe vendored in our repo. So, now i solve it with this bash script:
#!/bin/bash
set -uex
export LD_LIBRARY_PATH=./contrib/caffe.arch32/lib/
function copy_deps {
libs=$(LD_TRACE_LOADED_OBJECTS=1 /lib/ld-linux.so.2 "$1" | cut -d" " -f 3 | sort |uniq | grep -v '^$')
for lib in $libs
do
cp -un "$lib" ./bundle
done
}
mkdir -p bundle
mkdir -p ./bundle/vlc/plugins
cp -r /usr/lib/vlc/plugins ./bundle/vlc
rm -rf ./bundle/vlc/plugins/lua
rm -rf ./bundle/vlc/plugins/gui
rm -rf ./bundle/vlc/plugins/visualization
for plugin in $(find ./bundle/vlc/plugins -name "*.so")
do
copy_deps "$plugin"
done
copy_deps ./detector
cp /lib/ld-linux.so.2 ./bundle
cp ./detector ./bundle
cp ./config.ini ./bundle
mkdir -p ./bundle/config
cp -r ./config/nn ./bundle/config
cp -r ./config/neuron ./bundle/config
echo "LD_LIBRARY_PATH=./ ./ld-linux.so.2 ./detector 2> /dev/null" > ./bundle/run.sh
chmod +x ./bundle/run.sh
zip -q -r bundle.zip bundle
It works fine, but only for executable build(we need shared lib too), only for x86_32 distros. We build our project with cmake, so after reading it's docs i noticed, that fixup_bundle is cmake-way for bundling. All examples and blogs about fixup_bundle is very simple, or related with OSX or Windows. So, i append my CMakeLists.txt
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})
set(BUNDLE_NAME ${PROJECT_NAME})
set(BUNDLE_PATH "${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME}")
set(APPS ${BUNDLE_PATH})
list(APPEND DIRS ${CMAKE_INSTALL_PREFIX}/${LIBDIR} ${CAFFE_LINK_PATH} /lib/ /usr/lib)
list(APPEND LIBS)
INSTALL(CODE "
include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"${LIBS}\" \"${DIRS}\")
" COMPONENT Runtime)
And then try to run make install, I noticed that only our custom libcaffe is bundled, no boost, no opencv, no VLC. Why? How to bundle all dependencies?
OS: Arch Linux.

Is it possible to bundle js and css files separately using browserify

The command I'm using is
browserify -t browserify-css src\app.js > bundle.js
And css files that are traversed end up as text blobs in the bundle.js files which ultimately get appended as style tags to the head when loaded in a browser.
Is it be possible to output both a bundle.js and bundle.css file, where the bundle.css is just the concatenation of all css files that were traversed?
The src\app.js in this example contains only one require
require( 'app.css' );
You can use the sheetify transform, which outputs code that uses insert-css. Then, use the css-extract browserify plugin to extract the insert-css calls into a separate file.
browserify -t sheetify/transform -p [ css-extract -o bundle.css ] index.js \
-o bundle.js

Simple browserify test only runs when built with --debug

I have a simple hello world script main.js:
window.addEventListener('load', function() {
"use strict";
document.getElementById('output').textContent = "Hello, browser.";
});
If I build bundle.js with:
browserify -r ./main.js > bundle.js
It doesn't run in the browser. No errors, just doesn't execute. If I use:
browserify -r --debug ./main.js > bundle.js
It runs fine. Why doesn't the non-debug one run?
-r means require. -> -r file.js means, that you will put it into a seperate scope to require it in an other bundle, but it don't will execute.
Your "solution" -r --debug (or short -r -d) works, because the require attribute has no parameter/file, so it will be ignored by browserify.
Just removing -r --debug should solve your problem.
This...
browserify -r --debug ./main.js -o ./bundle.js
...is the same as this:
browserify -d ./main.js -o ./bundle.js

Uglifyjs does not generate working map file when uglifying browserify output

I've run browserify like this:
browserify js/app.js -d | exorcist js/bundle.js.map > js/bundle.js
When I load this in Chrome, the sources map file is fine. When I uglify it like this:
uglifyjs js/bundle.js --in-source-map js/bundle.js.map --source-map-url bundle2.js.map --source-map js/bundle2.js.map -o js/bundle2.js -p 1
The sources map file does not work. It tries to load sources from /js/js, instead of just from /js. I have fiddled with the -p parameter, and every other parameter that is documented on the commandline here:
https://github.com/mishoo/UglifyJS2
The only way I could get this to work was to cd into the js directory and run the commands from there. Lame, but it works.
-p relative
fixed the issue for me