Open willm opened 9 years ago
If I understand correctly, you want to have something as an alias or short cut of "wibble"
to "nested/path/wibble"
, right ? If not, what is your pain here ?
In this case, this should work, but keep in mind:
requirejs.config.json
file thing works only for template: 'UMD'
(http://urequire.org/umd-template) and of course the file is read only when executing on nodejs. So you're right on having to call require.config()
on a web environment (perhaps on main.js
, perhaps somewhere else).bundle.copy
, by default it copies nothing../source
or use a require(['wibble'], ...
?PS: I would NOT use dstPath: './scripts/build'
under path: './scripts'
- better keep 'em separated into ./source
& ./build
or something.
Thanks for your response, I tried switching the template to UMD, and moved the build directory up a level. However the requirejs.config.json
still doesn't appear to be processed. You say I'll need to call require.config(x)
however, what do I pass into this method as x?
The reason I'm trying to do this is I have some "legacy" cleint side codewritten in AMD. I would like to use urequire to deprecate the use of amd gradually, so that I can use commonjs modules throughout the entire application (the server is written in nodejs) without having to rewrite all the client side code in one go. The existing client side code has several aliases mentioned in the requirejs config. I'd like to avoid having to change too much of the structure of the code which is why I'm looking to use the existing aliases.
Is there an example using the requirejs.config.json somewhere?
However the requirejs.config.json still doesn't appear to be processed.
What do you mean not processed ? Is it copied to the build.dstPath
?
It would help if you can give access to your repo OR if you can create a minimalistic repo with sample files that follow your problem, so we can test your scenario.
You say I'll need to call
require.config(x)
however, what do I pass into this method as x?
The require.config(x)
is for the browser enironement only - you should pass the same config as in requirejs.config.json` (which is used only on the node env.).
Hope this helps
Sure, I've created a repo which hopefully explains the issue.
git clone https://github.com/willm/urequire-issue.git
npm install
urequire config urequire-config.js
If you then open test.html in your browser and look at the javascript console, you will see a script error for wibble. The requirejs.config.json will not appear anywhere in the build directory.
Again thank you for your help with this.
Sorry my friend, I have been hectic with work - I will look into this over the next few days and I will get you an answer - hope this is ok !
In your urequire-config.js
you were limiting bundle.filez
to *.js
only, and also bundle.copy
by default doesn't copy anything. So requirejs.config.json
wasn't being copied.
Changing these (running in node), it caused another problem (crashing, internal to uRequire) which I will have to look closer...
Hopefully this week!
Regards and sorry for delayed response... new country, new job, new life you see!
Regards
Also in your HTML, I guess you should be calling require.config({})
passing the same config as in requirejs.config.json
for the paths aliases.
Hi,
I'm trying to use a requirejs config (speciically the paths option). I've followed the guide and added a requirejs.config.json file at the root of my bundle, however, the built code does not seem to be using the config.
My project structure looks like this: scripts --nested ----path ------wibble.js --main.js --require.js --requirejs.config.json
my urequire config looks like:
my main.js looks like:
my requirejs.config.json looks like:
Do I need to call
require.config()
in main.js? If so what do I pass to it? It also doesn't seem like requirejs.config.json is being copied to the build folder. I tried adding it explicitly to the urequireconfig bundle.copy array which did copy it, but it is still not being used. Thanks for any help!