browserify

Allow global transforms with grunt browserify

只谈情不闲聊 提交于 2019-12-22 12:19:21
问题 I've added jQuery as a script tag in my html file and have added it to package.json for working with browserify-shim as follows: "browserify": { "transform": [ "browserify-shim" ] }, "browserify-shim": { "jquery": "global:jQuery" }, I'm able to expose it in my main script file with a simple require('jquery') call. The problem is that I'm using some jQuery plugins which internally do a require('jquery') and since browserify transforms don't apply to dependency of dependencies, it's causing

How to specify browserify extensions in package.json?

半城伤御伤魂 提交于 2019-12-22 10:20:03
问题 In package.json: ... "browserify": { "transform": [ "coffee-reactify" ], "extension": [ ".cjsx", ".coffee", ".js", ".json" ], "extensions": [ ".cjsx", ".coffee", ".js", ".json" ] }, ... When using browserify transform option works as expected, however browserify is not seeing extension(s) options - it throws error and I have to pass extension options manually to browserify... in gulpfile.coffee b = browserify entries: './' # ./ = root = directory where package.json is debug: true b.bundle()

Using Browserify with JQuery - what does it 'really' mean?

旧街凉风 提交于 2019-12-22 09:49:50
问题 New to javascript, etc. I wanted to do a pure HTML/Javascript project. I looked at requireJS, and from what I read, it seemed to me that a few projects went through the pain of switching their requireJS project to node/browserify projects. So I thought I just start with a node/browserify project. My limited understanding is that when you browserify a project, it basically packages the dependencies along with your javascript. Couple of questions Does it create just one file? If it creates

Getting Karma, 6to5ify and Istanbul to play ball

两盒软妹~` 提交于 2019-12-22 05:04:19
问题 I have Browserify, 6to5ify and Karma to play nice, successfully running my specs. When I add code coverage however, things go south. I've tried several approaches: Add browserify-istanbul transform to my karma.conf.js. However, this results in it trying to run instrumentation on my spec-files as well it would appear. Run coverage preprocessor on my source files. But because istanbul (even douglasduteil/karma-coverage#next ) doesn't read my 6to5ify browserify transform, this crashes

$ is not a function. Backbone, jQuery and Browserify

谁都会走 提交于 2019-12-22 04:48:17
问题 I am creating node app with browserify to modularize frontend code. Unfortunately, I can't get Backbone working, because it's throw this error: Uncaught TypeError: Property '$' of object #<Object> is not a function jQuery is loaded before this script: var _ = require('underscore'), Backbone = require('backbone'); // Here, jQuery works fine. $(function() { Backbone.history.start(); }); It's seem like Backbone couldn't find jQuery when using browserify. 回答1: Just set Backbone.$ = window.$

Browserify require returns an empty object

北城以北 提交于 2019-12-22 01:24:53
问题 I have this code which, for reasons I can't understand, produces an empty object when using require() . My file structure is like this: src |__ public |__ javascript |__ collections | categories.js | listings.js <-- Always an empty object |__ models | category.js | employer.js | listing.js | location.js | routing | templates | tests | ui-components | views The problem file is collections/listings.js , which seems to simply output as an empty object when required like so: var

Backbone app with CommonJS and Browserify

拥有回忆 提交于 2019-12-22 00:00:08
问题 I thinking of bringing my existing app over to using CommonJS modules and using Browserify to bundle up the modules into one file. I'm getting my head around writing modules but the one thing I'm a little sceptical before I dive in and start re-writing certain bits, is how can I optimise it slightly so I don't have to include Backbone, Underscore, jQuery and any helper files in in each file, ie. var Backbone = require('/backbone'); var $ = require('/jquery'); var _ = require('/underscore');

How to upload files from dropzone to cloudinary

心不动则不痛 提交于 2019-12-21 22:36:33
问题 var myDropzone = new Dropzone("#product-image-drpzone", { // Prevents Dropzone from uploading dropped files immediately autoProcessQueue: false, addRemoveLinks: true, autoQueue: false, acceptedFiles: '.jpg,.png,.jpeg,.gif', url: 'https://api.cloudinary.com/v1_1/something/image/upload', //put it in the main url file once done maxfilesexceeded: function (file) { ToasterWrapper.errorMessage('You have uploaded more than 4 images!', false); return; }, init: function () { // You might want to show

How to solve a conflict between browserify (Backbone based app) and require.js on the same page?

半城伤御伤魂 提交于 2019-12-21 19:38:09
问题 I have a backbone app up and running correctly. It's meant to be used as a widget in 3rd pages. Unfortunately, I just realised that one of these pages has already Backbone / underscore loaded. I get errors such as this: Uncaught TypeError: Cannot read property 'extend' of undefined Which usually appear when underscore has not been previously loaded. My typical view is like this: (normal Backbone view) ./view1.js var Backbone = require('backbone') var _ = require('underscore') var $ = require(

React and Grunt - Envify NODE_ENV='production' and UglifyJS

喜夏-厌秋 提交于 2019-12-21 04:35:11
问题 I am using Grunt to build a React project and I want to have 'dev' and 'prod' flavours. As react docs says: To use React in production mode, set the environment variable NODE_ENV to production. A minifier that performs dead-code elimination such as UglifyJS is recommended to completely remove the extra code present in development mode. I am very new using grunt, browserify and stuff but let's see. First problem I have is with envify, I use it as a transform: browserify: { options: { transform