browserify

Browserify multiple files into a single bundle

为君一笑 提交于 2019-12-05 18:49:39
Currently, I browserify a single js file into a bundle.js $ browserify X1.js --standalone XXX > bundle.js What if I have multiple js files and want to join them into a single browserified bundle.js How should the command look like? Can I do something like this? $ browserify X1.js X2.js --standalone XXX > bundle.js I am using node.js v6 You have already answered your own question. I confirm that it is correct. $ browserify X1.js X2.js --standalone XXX > bundle.js 来源: https://stackoverflow.com/questions/40484355/browserify-multiple-files-into-a-single-bundle

How can I require a html template with Browserify

荒凉一梦 提交于 2019-12-05 18:48:17
问题 I'm trying to figure out an easy way to require a html template in the script and then run browserify from the CLI. Say I want to grab a template and append it to the body. //index.js var template = require('./template.html'); document.body.appendChild(template); and <!-- template.html --> <p>Woooo!</p> Then using the CLI to wrap it all up in Browserify. browserify index.js > build.js When loading an index.html template in the browser that references build.js I get this error in the console:

Gulp Typescript + Browserify; Bundled sourcemap points to transpiled JS rather than source TS

依然范特西╮ 提交于 2019-12-05 13:12:59
I'm working on a Typescript project that is transpiled to ES5 JS and then run through browserify to create a single .js bundle and sourcemap. The bundled sourcemaps point to the transpiled JS rather than the source TS even though I am generating sourcemaps which properly point to the source TS when transpiling to JS. It's as if browserify is ignoring the existing sourcemaps pointing to the TS code and creating its own new maps to the transpiled JS code. Here are my gulp tasks for reference- code is compiled to a temp folder and then browserified from there. This uses browserify-incremental to

Empty object require angular browserify

无人久伴 提交于 2019-12-05 12:24:16
I m facing a problem when I try to use bowserify, angularjs and coffeescript. In fact, when I try to require('angular'), I get an empty object : angular = require('angular') console.log angular ## return an empty object {} configuration = require('../../config/config') console.log configuration ## returns my fully config file correctly I dont know why it doesn't work properly in this case :-/. This is my package.json where I put the my personnal angular dependencies : { "dependencies": { "gulp": "*", "gulp-browserify": "*", "coffeeify": "*", "gulp-concat": "*" }, "browser": { "angular": "./app

Browserify insert global variable

狂风中的少年 提交于 2019-12-05 07:58:04
Despite there are a lot of relative questions, they do not answer how to resolve the following issue. I have a nodejs file index.js. var browserify = require('browserify'); var data = getSomeData(); browserify('entry.js').bundle(); I want so that data could be accessed in entry.js . I found browserify option insertGlobalVars but I could not find any proper documentation or examples. I tried {insertGlobalVars: {myVar: someData}} but it does not work. I could not call require('someData') because my data is produced only when executing index.js . Update : Data is an array; key is a file name,

Gulp with browserify: Cannot find module src/js/main.js

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 07:43:52
I'm trying to get a basic build set up using Gulp and browserify, but keep seeing this error when trying to run the default task: Error: Cannot find module 'src/js/main.js' from '/Users/ben/dev/git/myapp/' gulpfile.js var gulp = require('gulp'); var browserify = require('browserify'); var del = require('del'); var source = require('vinyl-source-stream'); var paths = { main_js: ['src/js/main.js'], js: ['src/js/*.js'] }; gulp.task('clean', function(done) { del(['build'], done); }); gulp.task('js', ['clean'], function() { browserify(paths.main_js) .bundle() .pipe(source('bundle.js')) .pipe(gulp

$ is not a function. Backbone, jQuery and Browserify

只谈情不闲聊 提交于 2019-12-05 07:08:56
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. Just set Backbone.$ = window.$ manually. Backbone looks for jquery in a global variable (which is defined by capturing this ) and it's likely

How to use typescript modules w/ browserify?

一曲冷凌霜 提交于 2019-12-05 06:10:51
I'm new to typescript and I'm currently using CJS w/ help from browserify. When I added typescript to the mix the TSC compiler complains about require saying error TS2095: Could not find symbol 'require' This is my entry point for browerify var Hello:any = require('hello.js').Hello; here is my hello js file (required above) var React = require('react'); var Hello = React.createClass({displayName: 'Hello', render: function() { return React.DOM.div(null, "Hello ", this.props.name); } }); exports.Hello = Hello; You can fix this for any class by making declarations which tell Typescript how to

Browserifying react with addons to a standalone component, usable by plugins

北战南征 提交于 2019-12-05 05:35:19
I am experementing a bit with react and browserify and have these wishes: I want to bundle all code written by me into a single file I want to bundle all 3rd party dependencies (react, react-router, lodash etc) into separate files, one for each lib, to maximize caching possibilities I have managed to do the things described above but I ran into this specific situation: In some places of my code I want to use react with addons and as such require it like this: var React = require('react/addons) . I don't do this in all parts of my code and it is not done in 3rd party dependencies such as react

Getting Karma, 6to5ify and Istanbul to play ball

醉酒当歌 提交于 2019-12-05 05:08:40
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 immediately on the first file it tries to parse (because of the import statement), or when I use karma-coverage