-
-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ module.exports = function(yargs) { | |
describe: | ||
"Initializes a new webpack configuration or loads a" + | ||
"\n" + | ||
"plugin if specified", | ||
"addon if specified", | ||
group: INIT_GROUP | ||
}, | ||
migrate: { | ||
|
@@ -53,14 +53,21 @@ module.exports = function(yargs) { | |
describe: "Generates a new webpack plugin project", | ||
group: INIT_GROUP | ||
}, | ||
|
||
config: { | ||
type: "string", | ||
describe: "Path to the config file", | ||
group: CONFIG_GROUP, | ||
defaultDescription: "webpack.config.js or webpackfile.js", | ||
requiresArg: true | ||
}, | ||
"config-register": { | ||
type: "string", | ||
alias: "r", | ||
This comment has been minimized.
Sorry, something went wrong. |
||
describe: "Allows to use import/export in the webpack configuration", | ||
group: CONFIG_GROUP, | ||
defaultDescription: "@std/esm or babel-register", | ||
requiresArg: true | ||
}, | ||
This comment has been minimized.
Sorry, something went wrong.
jdalton
|
||
"config-name": { | ||
type: "string", | ||
describe: "Name of the config to use", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,8 @@ var fs = require("fs"); | |
fs.existsSync = fs.existsSync || path.existsSync; | ||
var interpret = require("interpret"); | ||
var prepareOptions = require("./prepareOptions"); | ||
|
||
module.exports = function(yargs, argv, convertOptions) { | ||
var options = []; | ||
|
||
// Shortcuts | ||
if (argv.d) { | ||
argv.debug = true; | ||
|
@@ -27,7 +25,6 @@ module.exports = function(yargs, argv, convertOptions) { | |
argv.mode = "production"; | ||
} | ||
} | ||
|
||
var configFileLoaded = false; | ||
var configFiles = []; | ||
var extensions = Object.keys(interpret.extensions).sort(function(a, b) { | ||
|
@@ -85,7 +82,6 @@ module.exports = function(yargs, argv, convertOptions) { | |
} | ||
} | ||
} | ||
|
||
if (configFiles.length > 0) { | ||
var registerCompiler = function registerCompiler(moduleDescriptor) { | ||
if (moduleDescriptor) { | ||
|
@@ -108,7 +104,26 @@ module.exports = function(yargs, argv, convertOptions) { | |
|
||
var requireConfig = function requireConfig(configPath) { | ||
var options = (function WEBPACK_OPTIONS() { | ||
return require(configPath); | ||
This comment has been minimized.
Sorry, something went wrong.
jdalton
|
||
if (argv.configRegister === "@std/esm") { | ||
return require(path.resolve( | ||
process.cwd(), | ||
"node_modules", | ||
"@std/esm" | ||
))(module, { | ||
esm: "js" | ||
})(configPath); | ||
} else if (argv.configRegister === "babel-register") { | ||
require(path.resolve( | ||
process.cwd(), | ||
"node_modules", | ||
"babel-register" | ||
))({ | ||
presets: ["es2015"] | ||
}); | ||
return require(configPath); | ||
} else { | ||
return require(configPath); | ||
} | ||
})(); | ||
options = prepareOptions(options, argv); | ||
return options; | ||
|
👆 The
type
should be an"array"
to allow for multiple-r
calls.Folks will stack them like
-r @std/esm -r @babel/register
.