requirejs / almond

A minimal AMD API implementation for use after optimized builds
Other
2.42k stars 169 forks source link

Location of almond.js is critical to the build process? #98

Open crishushu opened 9 years ago

crishushu commented 9 years ago

Thanks for your answer here!

Thereafter I was stumbling over this case, where the build process behaves as expected only if almond.js exists in example-project/src/almond.js and is used together with the corresponding pointer to the almond module name: '../almond' inside the build config file. The generated file example-project/www/almond.js contains the content of main.jswith all its dependencies.

Though what is wrong with the following setting? It does not write out any compressed file.

tree structure:

|── example-project/
|   |–– build-config.js
|   |–– node_modules/
|   |   |–– almond/
|   |   |   |–– almond.js
|   |–– src/
|   |   |–– index.html
|   |   |–– example-frag.js
|   |   |–– core/
|   |   |   |–– main.js
|   |   |   |–– other.js

build config file:

({
    baseUrl: 'core',
    appDir: 'src',
    dir: 'www',
    name: 'node_modules/almond/almond',
    insertRequire: ['main'],
    include: ['main'],
    optimize: 'uglify2',
    preserveLicenseComments: false,
    generateSourceMaps: true,
    skipDirOptimize: true,
    removeCombined: true,
    wrap: {
        startFile: 'src/example-frag.js'
    },
    paths: {        
        main: 'main',
        other: 'other'
    }
})

BTW using out: instead dir: just works fine regardless where almond.js is located.