Require.js not compiling single js file correctly

前端 未结 2 1307
耶瑟儿~
耶瑟儿~ 2020-12-16 17:17

I\'m trying to build my require.js modules to one javascript file for production.

The command I\'m running is...

r.js -o name=main out=main.min.js m         


        
相关标签:
2条回答
  • Quick fix: use r.js -o build.js instead of node r.js -o build.js


    I had the problem when I was trying to call r.js through node:

    node r.js -o build.js

    Calling r.js directly fixed the problem:

    r.js -o build.js

    Note: r.js was installed globally with npm install -g requirejs

    0 讨论(0)
  • 2020-12-16 17:51

    You're correct, you need to include requireJS in your build. Take a look at http://requirejs.org/docs/optimization.html#onejs. You'll find an example for the command line there. If you're using a build profile it will look something like this -

    ({
    baseUrl: "../Scripts",
    paths: {
        requireLib: 'libs/require'
    },
    name: "main",
    out: "main-built.js",
    include: ["requireLib"]
    })
    
    0 讨论(0)
提交回复
热议问题