requirejs

Angular项目构建指南

旧街凉风 提交于 2019-12-20 19:22:29
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 前言 接触Angular也有小半个月了,虽然没有使劲折腾,不过正所谓"no zuo no die".学一门新东西,不好好折腾一下总觉得对不起祖国,最不起人民...好像扯远了,想写前言来着.为什么要写这篇构建指南?最大的原因是为了给正在找这方面资料,挣扎于各种说法中的同学一个借鉴,同时我也把自己的经验记录下来,两全其美. 正文 如果你不知道什么是Angular或者根本没听说过,那么我接下来所说的对你来说毫无益处,不过如果你打算以后会接触Angular或者干脆要涨涨姿势~读下去还是有点用的. Angular和它之前所出现的其余前端框架最大的不同,在于它的核心不再是DOM,而是数据,是model.我们惯用的不管是单纯的jQuery还是MVC的Backbone,它们本质仍是让我们更方便更有条理的操作DOM,但是Angular不是.通过一系列魔术般的手法,它将一切的重心转移到数据上.以开发应用而不是操作节点的方式去开发Web,一切以数据为中心,数据的变化驱动了一切,包括行为. 文本主题,如何构建一个angular项目? 坦白说最开始构建一个项目的时候,虽然很小但是很纠结.我本身是有点完美主义的,所以虽然一开始什么都没有也想做到尽善尽美.因为听过很多前辈的经验,说如果框架基础没搭好,等到后来不管是重构还是维护都是一场噩梦

How to change module timeout in Require.js?

守給你的承諾、 提交于 2019-12-20 17:35:01
问题 When I am on slow mobile broadband I sometimes get: Uncaught Error: Load timeout for modules: goog!maps,3,other_params:sensor=false_unnormalized2,goog!maps,3,other_params:sensor=false,async!http://www.google.com/jsapi I would like to raise the timeout for similar users as me sometimes using mbb. 回答1: See waitSeconds config value from RequireJS docs: http://requirejs.org/docs/api.html#config-waitSeconds Per the docs, the default is 7 seconds. You can set it in your require.config call like

Using requirejs optimizer node module with Gulp

£可爱£侵袭症+ 提交于 2019-12-20 14:43:40
问题 There's gulp-requirejs plugin, but it's blacklisted with the following message: "use the require.js module directly". The docs are quite sparse, how would I best use it in conjunction with Gulp build task? In the docs there's an example: var requirejs = require('requirejs'); var config = { baseUrl: '../appDir/scripts', name: 'main', out: '../build/main-built.js' }; requirejs.optimize(config, function (buildResponse) { //buildResponse is just a text output of the modules //included. Load the

How to structure multiple pages with RequireJS

我与影子孤独终老i 提交于 2019-12-20 14:21:11
问题 How to structure multiple pages with RequireJS? Is, like the following sample, declaring every class in app.js is the right thing to do? Has every html file to declare the <script data-main="src/main" src="src/require.js"></script> ? What I want to avoid is loading all the script when a user reach the first page of a site. main.js defining all external dependencies: require( { baseUrl:'/src' }, [ "require", "order!http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", "order!http:/

Webpack with requirejs/AMD

假如想象 提交于 2019-12-20 12:38:40
问题 I'm working on a new module for an existing project that still uses requireJS for module loading. I'm trying to use new technologies for my new module like webpack (which allows me to use es6 loaders using es6 imports). It seems like webpack can't reconcile with requireJS syntax. It will say things like: "Module not found: Error: Can't resolve in ". Problem : Webpack won't bundle files with requireJS/AMD syntax in them. Question : Is there any way to make webpack play nice with requireJS? My

Registering Grunt tasks whose code is located in external JavaScript files

不想你离开。 提交于 2019-12-20 11:55:28
问题 I've written a function which I'd like to use as a Grunt task. I can do this by adding this to the Gruntfile: grunt.registerTask('foo', function () { // code here }); However, it makes more sense to keep the function code in a separate file. I plan to define a bunch of these custom tasks and I don't want to bloat the Gruntfile. I'm not sure what the preferred way of registering such tasks is. I have found this to work: grunt.registerTask('foo', function () { require('./path/to/foo.js')(grunt)

Why my Mobile Safari cache won't clear?

家住魔仙堡 提交于 2019-12-20 09:53:39
问题 I'm trying to debug a site on my iPhone4 (iOS4) iPad1 (iOS3.3) and desktop. My problem is I cannot clear the iPhone cache at all. If I add alerts/consoles to the js files I'm debugging, they show up on iPad and desktop, but the iPhone just keeps reloading from the cache. If I clear the cache through settings>safari>delete browser history, cache, cookies and in Safari delete all bookmarks and remove the files on the server, iPad and desktop break (missing files) but the iPhone still loads the

Webpack: expressing module dependency

主宰稳场 提交于 2019-12-20 08:59:42
问题 I'm trying to require the bootstrap-webpack module in my webpacked application. It appears to need jQuery, since the bundled javascript then throws the following: Uncaught ReferenceError: jQuery is not defined How do I go about specifying to webpack that jQuery is a dependency for the bootstrap-webpack module, to fix this issue? It feels like it should be trivial, but I've been struggling to figure it out. I've tried adding: "jquery": "latest" to the dependecies in the bootstrap-webpack's

RequireJS: Multiple main.js?

一世执手 提交于 2019-12-20 08:48:48
问题 I have been building a single page app using requireJS and so far loving it. I have come to the point of developing other parts of the site outside of the main app and am not really sure how (or if) to use requireJS for this. In my main app everything is triggered by this script tag: <script data-main='/scripts/main' src='/scripts/libs/require.js'> I am now developing the home page which has it's own front end scripts. Using the optimizer when it comes to getting the site live which will

Explanation of define of the RequireJS library

给你一囗甜甜゛ 提交于 2019-12-20 08:36:13
问题 I started to read several tutorials about RequireJS. In none of them was the "define" keyword explained satisfactorily for me. Could someone help me with the following : define( ["Models/Person", "Utils/random", "jquery"], function (Person, randomUtility, $) {..} ) What is "define"? Is define a function with an array and an anonymous function inside of it? Or is it something else? Can someone give me more information about this kind of definitions? Addition: Thank you nnnnnn and pradeek for