webpack web-webpack-plugin插件的template属性配置成函数之后无法打包

最近在研究webpack多页面,用到一个web-webpack-plugin插件,在测试多页输出时,配置template这个属性后编译无法通过,代码如下
webpack.config.js

const { WebPlugin,AutoWebPlugin } = require('web-webpack-plugin')
const path = require('path')
module.exports = {
  entry: {
    app: './src/main.js'
  },
  output: {
    path: path.resolve(__dirname, 'dist/'),
    filename: '[name][hash].js'
  },
  plugins:[
    new AutoWebPlugin('./src/page/', {
      template: (pageName) => {  //配置此处后,webpack编译就报错了,
       return path.resolve('./src/page/',pageName,'index.html');
      },
            ignorePages: ['ignore'],
            commonsChunk: {
                name: 'common',// name prop is require
                minChunks: 2,
            },
            outputPagemap: true,
        }),
  ]
}

看官方手册配置完template属性后,发现打包报错 内容如下:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.module has an unknown property 'strictThisContextOnImports'. These properties are valid:
   object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, loaders?, noParse?, rules?, unknownContextCritical?, unknownCon
textRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp?, strictExpo
rtPresence? }

   Options affecting the normal modules (`NormalModuleFactory`).

几经尝试后无果,求大佬指点

阅读 3.7k
1 个回答

同是新手,没有用过你说的那个插件。但是多页面的话,直接指定多个entry,用html-webpack-plugin提取多个html文件都是可以的

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题