forked from winjs/winjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up modular build to support custom CSS.
This makes some changes to our modular build to not pre-bundle public modules. It also enables support for compiling custom CSS by providing a Node build script to invoke the r.js optimizer instead of relying on the commandline tool.
- Loading branch information
Showing
6 changed files
with
97 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
(function () { | ||
"use strict"; | ||
|
||
var path = require('path'); | ||
var fs = require("fs-extra"); | ||
var config = require("../config.js"); | ||
|
||
module.exports = function (grunt) { | ||
|
||
grunt.registerTask("build-modules", ["ts:src", "_copyToTsBuild", "copy:modules", "_setupModules"]); | ||
grunt.registerTask("_setupModules", "Set up the modules package", function () { | ||
|
||
// rename the main file | ||
fs.renameSync(path.join(config.modulesOutput, "WinJS.js"), path.join(config.modulesOutput, "WinJS-custom.js")); | ||
|
||
// require.js copies some undesirable source files over | ||
var toRemove = [ | ||
"_build.js", | ||
"WinJS/Utilities/_TelemetryImpl.js" | ||
]; | ||
toRemove.forEach(function (item) { | ||
fs.removeSync(path.join(config.modulesOutput, item)); | ||
}); | ||
|
||
var requirejs = grunt.config.get("requirejs"); | ||
|
||
var pkgRoot = "node_modules/winjs-modules/"; | ||
var requireConfig = { | ||
baseUrl: ".", | ||
name: "WinJS-custom", | ||
deps: ["amd"], | ||
optimize: "none", | ||
useStrict: true, | ||
out: "bin/js/WinJS.js", | ||
wrap: { | ||
start: requirejs.header("WinJS-custom", []), | ||
end: requirejs.footer("WinJS-custom"), | ||
}, | ||
paths: { | ||
"amd": pkgRoot + "amd", | ||
"require-style": pkgRoot + "require-style", | ||
"require-json": pkgRoot + "require-json", | ||
"WinJS": pkgRoot + "WinJS" | ||
}, | ||
findNestedDependencies: true | ||
}; | ||
var output = JSON.stringify(requireConfig, null, 4); | ||
fs.writeFileSync(path.join(config.modulesOutput, "example.config.js"), output); | ||
}); | ||
|
||
}; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
"use strict"; | ||
var requirejs = require('requirejs'); | ||
var fs = require('fs'); | ||
|
||
var options = JSON.parse(fs.readFileSync('config.js', 'utf8')); | ||
|
||
requirejs.optimize(options, function (buildOutput) { | ||
console.log("Success"); | ||
console.log(buildOutput); | ||
}, function (err) { | ||
console.log("Error"); | ||
console.log(err); | ||
}); |