Pergunta

I have a unique situation where I need to have both the source and main.js in one file and for everything to initialize within that file, so no require calls on the page. Is this possible?

Foi útil?

Solução

If you want to include require.js with the main.js source, you can use this kind of command:

node ../../r.js -o baseUrl=. paths.requireLib=../../require name=main include=requireLib out=main-built.js

Since "require" is a reserved dependency name, you create a "requireLib" dependency and map it to the require.js file.

Once that optimization is done, you can change the script tag to reference "main-built.js" instead of "require.js", and your optimized project will only need to make one script request.

Source

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top