2013-01-31 01:49:25 +08:00
|
|
|
var should = require("should");
|
|
|
|
var path = require("path");
|
|
|
|
|
|
|
|
var webpack = require("../lib/webpack");
|
|
|
|
|
2013-02-01 16:08:06 +08:00
|
|
|
describe("Integration", function() {
|
2013-01-31 01:49:25 +08:00
|
|
|
it("should compile library1", function(done) {
|
|
|
|
webpack({
|
|
|
|
entry: "library1",
|
|
|
|
context: path.join(__dirname, "browsertest"),
|
|
|
|
output: {
|
|
|
|
pathinfo: true,
|
|
|
|
path: path.join(__dirname, "browsertest", "js"),
|
|
|
|
filename: "library1.js",
|
|
|
|
library: "library1"
|
|
|
|
}
|
|
|
|
}, function(err, stats) {
|
|
|
|
if(err) throw err;
|
2013-02-01 16:08:06 +08:00
|
|
|
stats.hasErrors().should.be.not.ok;
|
|
|
|
stats.hasWarnings().should.be.not.ok;
|
2013-01-31 01:49:25 +08:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it("should compile library2", function(done) {
|
|
|
|
webpack({
|
|
|
|
entry: "library2",
|
|
|
|
context: path.join(__dirname, "browsertest"),
|
|
|
|
output: {
|
|
|
|
pathinfo: true,
|
|
|
|
path: path.join(__dirname, "browsertest", "js"),
|
|
|
|
filename: "library2.js",
|
|
|
|
publicPath: "js/",
|
|
|
|
library: "library2"
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
postLoaders: [
|
|
|
|
{
|
|
|
|
test: /extra2\.js/,
|
|
|
|
loader: "raw!extra!val?cacheable"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
optimize: {
|
|
|
|
maxChunks: 2,
|
|
|
|
},
|
2013-09-24 21:25:36 +08:00
|
|
|
define: {
|
|
|
|
CONST_TRUE: true,
|
|
|
|
CONST_FALSE: false,
|
|
|
|
CONST_FUNCTION: function() { return "ok"; },
|
|
|
|
CONST_NUMBER: 123,
|
|
|
|
CONST_NUMBER_EXPR: "1*100+23",
|
|
|
|
CONST_OBJECT: {
|
|
|
|
A: 1,
|
|
|
|
B: JSON.stringify("B"),
|
|
|
|
C: function() { return "C"; }
|
|
|
|
}
|
|
|
|
},
|
2013-01-31 01:49:25 +08:00
|
|
|
amd: {
|
|
|
|
fromOptions: true
|
|
|
|
},
|
|
|
|
plugins: {
|
|
|
|
"after-environment": function() {
|
|
|
|
this.resolver.plugin("module-resolved", function(request, callback) {
|
|
|
|
callback(null, request.replace(/extra\.js/, "extra2.js"));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, function(err, stats) {
|
|
|
|
if(err) throw err;
|
2013-02-01 16:08:06 +08:00
|
|
|
stats.hasErrors().should.be.not.ok;
|
|
|
|
stats.hasWarnings().should.be.not.ok;
|
2013-01-31 01:49:25 +08:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|