inline-script-plugin

0.0.7 • Public • Published

inline-script-plugin

加强 html-webpack-plugin 插件

将给定路径的script插入到所有js脚本的最前面, 或直接插入到head标签中

提供以inline的形式插入到html中

使用前确保有安装 html-webpack-plugin

安装

npm i inline-script-plugin -D

使用

inline-script-plugin添加到webpack插件配置当中:

// vue.config.js为例
const InlineScriptPlugin = require('inline-script-plugin')

module.exports = {
  xxx,
  chainWebpack: config => {
    config
      .plugin('InlineScriptPlugin')
      .after('html')
      .use(InlineScriptPlugin, [
        {
          name: 'abc', // yourName
          path: './a/b.js', // yourPath
          inhead: true,
          inline: true
        }
      ])
      .end()
  }
}

有关 options 配置如下:

字段名 参数类型 默认值 是否必填 说明
name String - 文件名
path String - 文件路径
inline Boolean false 是否以inline形式插入脚本
inhead Boolean false 是否将脚本插入到head标签里

Readme

Keywords

none

Package Sidebar

Install

npm i inline-script-plugin

Weekly Downloads

1

Version

0.0.7

License

ISC

Unpacked Size

7.72 kB

Total Files

5

Last publish

Collaborators

  • zhangcai93