当我使用webpack-cli init
创建一个新的webpack配置时,它会生成文件webpack.prod.js
或webpack.dev.js
,具体取决于我是否回答问题哪个模块将是第一个进入应用程序的模块? [默认:./ src / index]
如何自定义生成的配置文件的文件名?例如webpack.config.dev.js
webpack.config.js的默认名称是webpack.config.js,但您也可以在此对象中设置它,它们将被命名为。
您还可以使用查询创建3个配置,最后由您决定。默认入口点是index.js,但您也可以在提示中影响它们。
prompting() {
return this.prompt(
[
List( 'confirm', 'Welcome to the tnado Scaffold! Are you ready?', ['Yes', 'No', 'tnado'] ),
Input( 'entry', 'What is the entry point in your app?' )
]
).then( answer => {
// Build a configuration if the user chooses tnado. (custom config)
if ( answer['confirm'] === 'tnado' ) {
// Insert in config
// Common
this.options.env.configuration.config.webpackOptions = createCommonConfig( answer );
this.options.env.configuration.config.topScope = [
'const path = require("path")',
'const webpack = require("webpack")'
];
您也可以在webpackOptions中更改webpack.config.js名称,因为您还没有发布任何代码我假设您已经使用yeoman生成器扩展了目前为止的类。
const Generator = require( 'yeoman-generator' );
module.exports = class WebpackGenerator extends Generator {
Name your webpack config something special
如您所见,有很多方法可以影响名称;)