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;
|
var configPath, ext;
|
||||||
if (argv.config) {
|
if (argv.config) {
|
||||||
configPath = argv.config;
|
configPath = path.resolve(argv.config);
|
||||||
ext = path.extname(configPath);
|
ext = path.extname(configPath);
|
||||||
} else {
|
} else {
|
||||||
var found = Object.keys(interpret.extensions).some(function(extname) {
|
var extensions = Object.keys(interpret.extensions);
|
||||||
ext = extname;
|
for(var i = 0; i < extensions.length; i++) {
|
||||||
configPath = path.resolve('webpack.config' + ext);
|
var webpackConfig = path.resolve('webpack.config' + extensions[i]);
|
||||||
return fs.existsSync(configPath);
|
if(fs.existsSync(webpackConfig)) {
|
||||||
});
|
ext = extensions[i];
|
||||||
|
configPath = webpackConfig;
|
||||||
if (!found) {
|
break;
|
||||||
configPath = 'webpack.config.js';
|
}
|
||||||
ext = '.js';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var moduleName = interpret.extensions[ext];
|
if(configPath) {
|
||||||
if (moduleName) {
|
var moduleName = interpret.extensions[ext];
|
||||||
var compiler = require(moduleName);
|
if (moduleName) {
|
||||||
var register = interpret.register[moduleName];
|
var compiler = require(moduleName);
|
||||||
var config = interpret.configurations[moduleName];
|
var register = interpret.register[moduleName];
|
||||||
if (register) {
|
var config = interpret.configurations[moduleName];
|
||||||
register(compiler, config);
|
if (register) {
|
||||||
|
register(compiler, config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
options = require(configPath);
|
||||||
}
|
}
|
||||||
options = require(configPath);
|
|
||||||
|
|
||||||
if(typeof options !== "object" || options === null) {
|
if(typeof options !== "object" || options === null) {
|
||||||
console.log("Config did not export a object.");
|
console.log("Config did not export a object.");
|
||||||
|
|
|
@ -41,7 +41,7 @@ library1.on("exit", function(code) {
|
||||||
bindOutput(main);
|
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",
|
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);
|
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