|
4 | 4 | * see: http://github.com/jrburke/requirejs for details
|
5 | 5 | */
|
6 | 6 |
|
7 |
| -/*jslint regexp: false, plusplus: false, nomen: false, strict: false */ |
8 |
| -/*global define: false, require: false */ |
| 7 | +/*jslint plusplus: true, nomen: true */ |
| 8 | +/*global define, require */ |
9 | 9 |
|
10 | 10 |
|
11 | 11 | define([ 'lang', 'logger', 'env!env/file', 'parse', 'optimize', 'pragma',
|
12 | 12 | 'env!env/load', 'requirePatch'],
|
13 | 13 | function (lang, logger, file, parse, optimize, pragma,
|
14 | 14 | load, requirePatch) {
|
| 15 | + 'use strict'; |
| 16 | + |
15 | 17 | var build, buildBaseConfig,
|
16 | 18 | endsWithSemiColonRegExp = /;\s*$/;
|
17 | 19 |
|
@@ -532,32 +534,25 @@ function (lang, logger, file, parse, optimize, pragma,
|
532 | 534 | * to the absFilePath passed in.
|
533 | 535 | */
|
534 | 536 | build.makeAbsConfig = function (config, absFilePath) {
|
535 |
| - var props, prop, i, originalBaseUrl; |
| 537 | + var props, prop, i; |
536 | 538 |
|
537 | 539 | props = ["appDir", "dir", "baseUrl"];
|
538 | 540 | for (i = 0; (prop = props[i]); i++) {
|
539 | 541 | if (config[prop]) {
|
540 | 542 | //Add abspath if necessary, make sure these paths end in
|
541 | 543 | //slashes
|
542 | 544 | if (prop === "baseUrl") {
|
543 |
| - originalBaseUrl = config.baseUrl; |
| 545 | + config.originalBaseUrl = config.baseUrl; |
544 | 546 | if (config.appDir) {
|
545 | 547 | //If baseUrl with an appDir, the baseUrl is relative to
|
546 | 548 | //the appDir, *not* the absFilePath. appDir and dir are
|
547 | 549 | //made absolute before baseUrl, so this will work.
|
548 |
| - config.baseUrl = build.makeAbsPath(originalBaseUrl, config.appDir); |
549 |
| - //Set up dir output baseUrl. |
550 |
| - config.dirBaseUrl = build.makeAbsPath(originalBaseUrl, config.dir); |
| 550 | + config.baseUrl = build.makeAbsPath(config.originalBaseUrl, config.appDir); |
551 | 551 | } else {
|
552 | 552 | //The dir output baseUrl is same as regular baseUrl, both
|
553 | 553 | //relative to the absFilePath.
|
554 | 554 | config.baseUrl = build.makeAbsPath(config[prop], absFilePath);
|
555 |
| - config.dirBaseUrl = config.dir || config.baseUrl; |
556 | 555 | }
|
557 |
| - |
558 |
| - //Make sure dirBaseUrl ends in a slash, since it is |
559 |
| - //concatenated with other strings. |
560 |
| - config.dirBaseUrl = endsWithSlash(config.dirBaseUrl); |
561 | 556 | } else {
|
562 | 557 | config[prop] = build.makeAbsPath(config[prop], absFilePath);
|
563 | 558 | }
|
@@ -630,12 +625,13 @@ function (lang, logger, file, parse, optimize, pragma,
|
630 | 625 | var config = {}, buildFileContents, buildFileConfig, mainConfig,
|
631 | 626 | mainConfigFile, prop, buildFile, absFilePath;
|
632 | 627 |
|
633 |
| - lang.mixin(config, buildBaseConfig); |
634 |
| - lang.mixin(config, cfg, true); |
635 |
| - |
636 | 628 | //Make sure all paths are relative to current directory.
|
637 | 629 | absFilePath = file.absPath('.');
|
638 |
| - build.makeAbsConfig(config, absFilePath); |
| 630 | + build.makeAbsConfig(cfg, absFilePath); |
| 631 | + build.makeAbsConfig(buildBaseConfig, absFilePath); |
| 632 | + |
| 633 | + lang.mixin(config, buildBaseConfig); |
| 634 | + lang.mixin(config, cfg, true); |
639 | 635 |
|
640 | 636 | if (config.buildFile) {
|
641 | 637 | //A build file exists, load it to get more config.
|
@@ -697,6 +693,19 @@ function (lang, logger, file, parse, optimize, pragma,
|
697 | 693 | //args should take precedence over build file values.
|
698 | 694 | mixConfig(config, cfg);
|
699 | 695 |
|
| 696 | + |
| 697 | + //Set final output dir |
| 698 | + if (config.hasOwnProperty("baseUrl")) { |
| 699 | + if (config.appDir) { |
| 700 | + config.dirBaseUrl = build.makeAbsPath(config.originalBaseUrl, config.dir); |
| 701 | + } else { |
| 702 | + config.dirBaseUrl = config.dir || config.baseUrl; |
| 703 | + } |
| 704 | + //Make sure dirBaseUrl ends in a slash, since it is |
| 705 | + //concatenated with other strings. |
| 706 | + config.dirBaseUrl = endsWithSlash(config.dirBaseUrl); |
| 707 | + } |
| 708 | + |
700 | 709 | //Check for errors in config
|
701 | 710 | if (config.cssIn && !config.out) {
|
702 | 711 | throw new Error("ERROR: 'out' option missing.");
|
|
0 commit comments