multiple-webpack-plugin

1.0.3 • Public • Published

multiple-webpack-plugin

A plugin to help webpack realize multi page application

Install

npm install multiple-webpack-plugin --save-dev

Features

  • Concat
  • Inject to html(with html-webpack-plugin)

Usage

const MultipleWebpackPlugin = require("multiple-webpack-plugin");

// 初始化多页面插件
const moptions = {
  favicon: '', // 网站图标缩略图地址 (非必填)
  chunkPath: path.join(__dirname, "src/js"), // 入口js目录 (必填,默认src目录)
  chunkExt: ".js", // 入口文件后缀名,可传多个数组形式 (非必填,默认匹配第一个)
  templatePath: path.join(__dirname, "src/views"), // 模版目录 (必填,默认public目录)
  templateExt: ".html", // 模版后缀名,可传多个数组形式 (非必填,默认匹配第一个)
  separator: "__", // 文件名分割符号(当不同目录层级文件同名时,采用目录名加文件名方式)
  clap: false // 是否拍平目录名,对于多层目录名取距离文件最近的目录命名,且目录名不能为index
}
const { entry, plugins } = new MultipleWebpackPlugin(moptions);

// webpack配置
module.exports = {
  entry: entry,
  plugins: [
    (...) // 其他plugin
    ...plugins,
  ]
}

Options

favicon [string | null] default: null

site logo thumbnail

chunkPath [string | array] default: "src"

directory of the entry file

chunkExt [string | array] default: ['.js','.jsx','.ts','.tsx']

entry file name suffix

templatePath [string | array] default: "public"

directory of the template

templateExt [string | array] default: ['.html', '.hbs', '.ejs']

template suffix

separator [string] default: '-'

file name divider

clap [boolearn] default: false

file name flattened

Package Sidebar

Install

npm i multiple-webpack-plugin

Weekly Downloads

3

Version

1.0.3

License

ISC

Unpacked Size

11.9 kB

Total Files

6

Last publish

Collaborators

  • wangwenshan