我正在使用r.js编译基于require.js的JavaScript。我们使用css插件。这是我正在运行的build.js:
var requirejs = require('requirejs');
var sys = require("sys");
var prop = require("./node/config.js");
var extend = require('node.extend');
var baseNoC=prop.base.replace("C:/","");
window = {
top: {
M4_CONFIG: {
path: prop.base + "/uif/trunk"
}
}
};
var amdConfig = require(prop.base + "/uif/trunk/scripts/bootstrap/amd-config");
var config = {
baseUrl: "C:",
name: "/"+baseNoC+"/uif/trunk/scripts/bootstrap/home-main.js",
out: "main-built.js",
optimize: "none",
map: {
'*': {
'css': baseNoC + "/vendor/trunk/require-plugins/require-css/0.0.3/css"
}
}
};
config = extend(config, amdConfig);
config.paths["all-files"]= window.top.M4_CONFIG.path + "/all-files";
//I tried it with this line in and out.
//config.paths["css"]="Projects/mercury/vendor/trunk/require-plugins/require-css/0.0.3/css";
requirejs.optimize(config, function(buildResponse) {
//buildResponse is just a text output of the modules
//included. Load the built file for the contents.
//Use config.out to get the optimized file contents.
var contents = fs.readFileSync(config.out, 'utf8');
}, function(err) {
//optimization err callback
sys.puts("error! " + err);
});
当我使用生成的JavaScript运行我的页面时,我得到“NetworkError:404 Not Found - [domain] /css.js”
文件的位置位于config.map上指定的位置。无论如何,我不明白为什么它不在我编译的JavaScript中。我该怎么办?
P.S。 我们正在使用Sass,我不介意只用Sass打包一个大css并告诉它忽略代码中的!css。 (但是,由于历史原因,这些都在那里。)