I'm trying to concatenate all my requires modules and a few text templates into a single concatenated and uglified main.min.js, so I can include that file in my HTML.
I figured out concatenation and uglifying part. However, I am not able to actually run any code in the browser then.
I created a bare-bone project on github, to reproduce the problem.
File structure:
- main.js
- index.html
- log.js
- build-production
- lib/require.js
- node_modules/require/bin/r.js
I concatenate main.js, log.js and require.js using the build file build-production:
./node_modules/requirejs/bin/r.js -o build-production.js
main.js
require.config({
paths: {
requireLib : 'lib/require/require'
},
waitSeconds: 1000
});
console.log('loading main.js');
define(function(require) {
var log = require('log');
console.log('loaded')
log.fine('main loaded');
});
build-production.js:
({
mainConfigFile : 'main.js',
include : [ 'requireLib' ],
name : 'main.js',
out : 'main.min.js' })
index.html:
<script src="main.min.js" type="text/javascript"></script>
so index.html in a browser should print out
loading main.js
loaded loaded main
but it only prints out the first line
loading main.js
anybody knows, why that is the case?
paths: { requireLib : 'lib/require/require' }in your build file. See here. - c24wmainConfigFile : 'main.js'. I tried it anyways. Didn't work - forste