mirror of https://github.com/webpack/webpack.git
parent
026170a8a3
commit
9a800d5979
|
@ -29,31 +29,32 @@ module.exports = function(optimist, argv, convertOptions) {
|
|||
|
||||
var configPath, ext;
|
||||
if (argv.config) {
|
||||
configPath = argv.config;
|
||||
configPath = path.resolve(argv.config);
|
||||
ext = path.extname(configPath);
|
||||
} else {
|
||||
var found = Object.keys(interpret.extensions).some(function(extname) {
|
||||
ext = extname;
|
||||
configPath = path.resolve('webpack.config' + ext);
|
||||
return fs.existsSync(configPath);
|
||||
});
|
||||
|
||||
if (!found) {
|
||||
configPath = 'webpack.config.js';
|
||||
ext = '.js';
|
||||
var extensions = Object.keys(interpret.extensions);
|
||||
for(var i = 0; i < extensions.length; i++) {
|
||||
var webpackConfig = path.resolve('webpack.config' + extensions[i]);
|
||||
if(fs.existsSync(webpackConfig)) {
|
||||
ext = extensions[i];
|
||||
configPath = webpackConfig;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var moduleName = interpret.extensions[ext];
|
||||
if (moduleName) {
|
||||
var compiler = require(moduleName);
|
||||
var register = interpret.register[moduleName];
|
||||
var config = interpret.configurations[moduleName];
|
||||
if (register) {
|
||||
register(compiler, config);
|
||||
if(configPath) {
|
||||
var moduleName = interpret.extensions[ext];
|
||||
if (moduleName) {
|
||||
var compiler = require(moduleName);
|
||||
var register = interpret.register[moduleName];
|
||||
var config = interpret.configurations[moduleName];
|
||||
if (register) {
|
||||
register(compiler, config);
|
||||
}
|
||||
}
|
||||
options = require(configPath);
|
||||
}
|
||||
options = require(configPath);
|
||||
|
||||
if(typeof options !== "object" || options === null) {
|
||||
console.log("Config did not export a object.");
|
||||
|
|
|
@ -41,7 +41,7 @@ library1.on("exit", function(code) {
|
|||
bindOutput(main);
|
||||
}
|
||||
});
|
||||
// node ../../bin/webpack --output-pathinfo --colors --output-library-target umd --output-jsonp-function webpackJsonpLib2 --output-public-path js/ --output-chunk-file [chunkhash].lib2.js --config library2config.js library2b library2 js/library2.js
|
||||
// node ../../bin/webpack --output-pathinfo --colors --output-library-target umd --output-jsonp-function webpackJsonpLib2 --output-public-path js/ --output-chunk-file [chunkhash].lib2.js --config library2config.coffee library2b library2 js/library2.js
|
||||
var library2 = cp.spawn("node", join(["../../bin/webpack.js", "--output-pathinfo", "--colors", "--output-library-target", "umd", "--output-jsonp-function", "webpackJsonpLib2",
|
||||
"--output-public-path", "js/", "--output-chunk-file", "[chunkhash].lib2.js", "--config", "library2config.js", "library2b", "library2", "js/library2.js"], extraArgsNoWatch));
|
||||
"--output-public-path", "js/", "--output-chunk-file", "[chunkhash].lib2.js", "--config", "library2config.coffee", "library2b", "library2", "js/library2.js"], extraArgsNoWatch));
|
||||
bindOutput(library2);
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
webpack = require("../../");
|
||||
module.exports =
|
||||
output:
|
||||
hashDigestLength: 5
|
||||
module:
|
||||
postLoaders: [
|
||||
{ test: /extra2?\.js/, loader: "raw!extra!val?cacheable" }
|
||||
]
|
||||
amd:
|
||||
fromOptions: true
|
||||
resolve:
|
||||
# cannot resolve should outside the outermost node_modules
|
||||
# so it is injected here
|
||||
alias:
|
||||
should: require.resolve "should"
|
||||
plugins: [
|
||||
new webpack.optimize.LimitChunkCountPlugin 2
|
||||
new webpack.DefinePlugin
|
||||
"typeof CONST_TYPEOF": JSON.stringify("typeof"),
|
||||
CONST_UNDEFINED: undefined,
|
||||
CONST_NULL: null,
|
||||
CONST_TRUE: true,
|
||||
CONST_FALSE: false,
|
||||
CONST_FUNCTION: -> return "ok";
|
||||
CONST_NUMBER: 123,
|
||||
CONST_NUMBER_EXPR: "1*100+23",
|
||||
CONST_OBJECT: {
|
||||
A: 1,
|
||||
B: JSON.stringify("B"),
|
||||
C: -> return "C";
|
||||
}
|
||||
new webpack.ProvidePlugin
|
||||
s3: "submodule3"
|
||||
->
|
||||
this.plugin "normal-module-factory", (nmf) ->
|
||||
nmf.plugin "after-resolve", (data, callback) ->
|
||||
data.resource = data.resource.replace /extra\.js/, "extra2.js";
|
||||
callback null, data;
|
||||
]
|
|
@ -1,48 +0,0 @@
|
|||
var webpack = require("../../");
|
||||
module.exports = {
|
||||
output: {
|
||||
hashDigestLength: 5
|
||||
},
|
||||
module: {
|
||||
postLoaders: [
|
||||
{ test: /extra2?\.js/, loader: "raw!extra!val?cacheable" }
|
||||
]
|
||||
},
|
||||
amd: {
|
||||
fromOptions: true
|
||||
},
|
||||
resolve: {
|
||||
// cannot resolve should outside the outermost node_modules
|
||||
// so it is injected here
|
||||
alias: { should: require.resolve("should") }
|
||||
},
|
||||
plugins: [
|
||||
new webpack.optimize.LimitChunkCountPlugin(2),
|
||||
new webpack.DefinePlugin({
|
||||
"typeof CONST_TYPEOF": JSON.stringify("typeof"),
|
||||
CONST_UNDEFINED: undefined,
|
||||
CONST_NULL: null,
|
||||
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"; }
|
||||
}
|
||||
}),
|
||||
new webpack.ProvidePlugin({
|
||||
s3: "submodule3"
|
||||
}),
|
||||
function() {
|
||||
this.plugin("normal-module-factory", function(nmf) {
|
||||
nmf.plugin("after-resolve", function(data, callback) {
|
||||
data.resource = data.resource.replace(/extra\.js/, "extra2.js");
|
||||
callback(null, data);
|
||||
});
|
||||
});
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue