browserify

Not working: require('react/addons')

和自甴很熟 提交于 2019-12-23 20:37:44
问题 I'm using ReactJS & Browserify. I can't figure out why this require doesn't give me access to ReactCSSTransitionGroup : var React = require('react/addons'); I tried adding this and it's still not working: var ReactCSSTransitionGroup = React.ReactCSSTransitionGroup; To get it working I had to add: var ReactCSSTransitionGroup = require("react/lib/ReactCSSTransitionGroup"); How can I gain access to all addons through: require('react/addons') ? 回答1: Requiring 'react/addons' simply adds the addons

Build React components with Gulp, Browserify and Babel

跟風遠走 提交于 2019-12-23 18:57:33
问题 I've created a React component and I want to distribute a built-in version (built with gulp) of this component, so in gulpfile.js I have: var gulp = require('gulp'); var browserify = require('browserify'); var babelify = require('babelify'); var source = require('vinyl-source-stream'); gulp.task('build-js', function() { return browserify('./src/Foo.js') .transform(babelify) .bundle() .pipe(source('bundle.js')) .pipe(gulp.dest('./dist')); }); gulp.task('build', ['build-js']); In .babelrc : {

reading a binary file in javascript using browserify

▼魔方 西西 提交于 2019-12-23 16:31:40
问题 I am trying to use browserify to access a local binary file (that is, the binary file is in the same directory as the javascript file, which is in the user's computer). I haven't succeeded. Here's what I tried and what I know: ~) I know fs won't work... 0) I tried using the require('html') but it says 'ajax not supported in this browser' [I am using chromium... but I'd assume it's roughly the same thing as chrome]. 1) I tried using 'browser-request'. This reads the binary file... as a string.

TinyMCE gulp configuration

纵然是瞬间 提交于 2019-12-23 11:02:29
问题 I am building a web application and I want to use TinyMCE. I am using gulp and browserify. I have downloaded TinyMCE through npm and than I have required it in my app.js file and run the gulp command but I got this error Failed to load: root/js/themes/modern/theme.js . I think this is because TinyMCE needs additional files from its folder. My question is how to configurate TinyMCE to search those files in the node_modules/tinymce folder. 回答1: The answer here depends completely on how you are

Redux NODE_ENV errors with Gulp/Browserify

时光总嘲笑我的痴心妄想 提交于 2019-12-23 09:28:05
问题 I'm getting this error message on a React/Redux app that is minified and packaged with Browserify and Gulp and deployed to Heroku. bundle.js:39 You are currently using minified code outside of NODE_ENV === 'production'. This means that you are running a slower development build of Redux. But it seems the build step is being done in NODE_ENV = 'production' . I've a task that set the env variables like so gulp.task('apply-prod-environment', function() { return process.env.NODE_ENV = 'production

Browserify's custom dependency name is not working

跟風遠走 提交于 2019-12-23 07:28:31
问题 I am trying to get browserify's custom dependency name working with memory streams. The reason I am using a memory stream is because this code is destined to run inside an AWS Lambda that will be receiving multiple "files" as inputs and will not be available to the lambda via the file system. According to the documentation at https://github.com/substack/node-browserify, it seems like this should be possible: b.require(file, opts) file can also be a stream, but you should also use opts.basedir

Cannot find module 'jquery' when using browserify

十年热恋 提交于 2019-12-23 03:45:08
问题 I am trying to use browserify for a small web application, what I would like to achieve is pretty basic: I would like to be able to require('jquery') in my JS code instead of having the dependency linked with a <script> tag in the HTML code. So, I have this in the first line of my JS file called main.js : require('jquery'); Then, I start browserify to produce bundle.js : browserify main.js -o bundle.js Output: Error: Cannot find module 'jquery' from /home/matias/dev/app/js However, it seems

Making Browserify bundle play nice with ReactDevTools

五迷三道 提交于 2019-12-23 02:18:43
问题 React 0.13.3 I started using Browserify to organize my frontend React code. I'm also using the React Developer Tools Chrome extension for debugging. However, I'm having trouble with some very simple React code. var React = require('react/addons'); //React DEV-TOOLS requires React to be on the global scope. Scope is hidden when bundling window.React = React; var App = React.createClass({ render: function(){ return ( <div> <p>Hello world</p> <!-- Renders fine --> </div> ) } }); React.render(

Import npm node_modules' css into Play Framework 2.4 app

感情迁移 提交于 2019-12-22 22:49:11
问题 I am trying several approaches to using Browserify with my play framework app, one of them is to use npm as package manager. A few modules are installed, and the typical node_modules folder appears at the root of the project. Using Browserify and Gulp, I was able to 'require' the Javascript from such modules and use it (take Bootstrap, for example). However, loading the CSS (e.g. for Bootstrap) I tried different things none of which would work. First, I tried to make it work in a plain HTML

React - Uncaught ReferenceError: require is not defined

六眼飞鱼酱① 提交于 2019-12-22 12:48:32
问题 I'm making a simple flask app, using react for the front-end stuff. Right now I'm experimenting with importing React components from other files, without success. This is the error I'm getting: Uncaught ReferenceError: require is not defined This is my html file: <html> <head> <meta charset="UTF-8"> <title>Index page</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.min.js"