browserify

Use node rework css in browser

笑着哭i 提交于 2019-12-24 07:16:57
问题 I would like to be able to use reworkcss/css in the browser. I downloaded version 2.0.0 from github and installed the needed packages with nmp install. I have tried requireJS (which claims to be able to process the CommonJS Module Format), requiring index.js, but an error occurs regarding "exports" being undefined. I also attempted to condense it using browserify, but this is evidently not what it was intended for. Does anyone know what I should do? I can't use node.js for the project, but

Inject data in a Browserify app

随声附和 提交于 2019-12-24 05:49:31
问题 Anyone here knows how to inject data into a Browserify app? I mean, I use Browserify to create a big bundle app.js file. But when my single page application starts, the server also add some bootstrap data into the HTML page that loads the app, so that the app doesn't have to do ajax requests to the server to get these data. For now the HTML template rendered by the server to start the app looks like that: <script type="text/javascript" > window.bootstrapData = @Html(utils.CustomSerializer

How to “remove”/“change” some require(…) calls when using browserify?

我与影子孤独终老i 提交于 2019-12-24 04:24:07
问题 I have app written in node.js that requires some npm modules (react, react-router and others). When I run browserify on it, then all npm modules are "injected" to the bundle.js file. What I want is to provide distribution for bower that won't include react and react-router dependencies in bundle.js file, because they can be referenced as dependencies in bower.json. app.js: var React = require('react') React.render(...) In bundle.js react is injected into it along with app.js I need bundle.js

Browserify and Reactify source maps include full local path names

≡放荡痞女 提交于 2019-12-24 04:15:50
问题 I use watchify/ browserify to create a bundle with debug source maps with this command- watchify main.js -o bundle.js -v -d When I use Chrome DevTools to debug the resulting app, the source files are accessible in their orginal nested folder locations, visible in DevTools' Sources panel. However when I run it through reactify with this command- watchify main.js -t reactify -o bundle.js -v -d Chrome DevTools shows all the source files in the same folder as bundle.js and the file name includes

Browserify resolves the same file multiple times

纵然是瞬间 提交于 2019-12-24 03:07:46
问题 I am facing a strange problem running latest browserify (10.2.4) and gulp. It seems that the same file is being resolved multiple times, and so I don't get the same instance when creating a singleton. I've put a 'debugger' before module.exports and verified it is called twice. note #1: I have a guess that says that browserify caches the files based on the string, and so when calling relative paths from different places will not have the same string, even though they point to the same place.

Why doesn't this jquery plugin need a shim in order to work?

瘦欲@ 提交于 2019-12-24 02:23:58
问题 Shimming a jQuery plugin appears to be only for geniuses who throw salt over the correct shoulder. However I did this.... var backbone = require('backbone'); global.jQuery = global.$ = backbone.$ = require('jquery'); require('./libs/jquery-modal'); $("body").Modal(); and it just works. (n.b. jquery is being loaded via debowerify) Why does this work? Would shimming it mean I don't need to do the assignments to jquery and $ ? And how is browserify able to handle my plugin code not being in the

Relative paths in package.json?

做~自己de王妃 提交于 2019-12-24 01:24:09
问题 I've got a project where src/main/webapp/com/mycompany/frontend/page/index.js depends on target/webjars/log4javascript/1.4.10/log4javascript.js . I've added package.json alongside index.js with the following contents: { "browser": { "log4javascript": "../../../../../../../target/webjars/log4javascript/1.4.10/log4javascript.js" } } I've got many other dependencies in the target directory. Is there a way for me to avoid repeating ../../../../../../../target/ for every dependency? 回答1: One

Why is it necessary to install Browserify twice to bundle

对着背影说爱祢 提交于 2019-12-24 01:21:47
问题 I created a new project I npm install -g browserify I tested using the cmdline, browserify app.js > bundle.js . Cool. I want to minify so I npm install uglifyify --save-dev I tested using the cmdline, browserify -g uglifyify app.js > bundle.js . Great. Now I want to do this with code, but I get Error: Cannot find module 'browserify' This is my code, basically to replace the cmdline var browserify = require('browserify') var fs = require('fs') var bundler = browserify('./app.js') bundler

How to simultaneously create both 'web' and 'node' versions of a bundle with Webpack?

我只是一个虾纸丫 提交于 2019-12-24 00:37:28
问题 Is there a way to create both 'web' and 'node' versions of a bundle with one go by using Webpack or Browserify? The 'web' version of the bundle will be used on a client, and 'node' version of the same bundle will be used on the server for pre-rendering ("isomorphic" web application). 回答1: I think the easiest way is probably just to create two configs, one with target: "node" and the other target: "web" in the configuration, and run them both like $ webpack && webpack --config webpack.config

Reduce Size of Large, React based Single Page Application's Browserify Bundle File

我只是一个虾纸丫 提交于 2019-12-24 00:28:56
问题 I am building a reactjs application using gulp and Browserify. I have used material-ui components in my application. There are 8 pages in my application using different components. The build.js created by Browserify is 4mb in size. I want to reduce its size. I have searched and learned a little about the lazy loading design pattern. But I am confused how it should be used to make the size smaller of my application? I am also using react router in my application so there are 8 routes defined.