1.0.7 • Published 2 years ago

hfex-auto-externals-plugin v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

hfex-auto-externals-plugin

中文文档

auto externals plugin,Plugins encapsulated using unplugin and html-webpack-plugin

html-webpack-plugin has introduced the getHooks method since version 4.0, so the html-webpack-plugin version used in your project must be at least 4.0

Currently supports:

install

npm install hfex-auto-externals-plugin -D

or

npx pnpm install hfex-auto-externals-plugin -D

or

npx yarn add hfex-auto-externals-plugin -D

usage

For example in Vue:

The vue version used in my project is 3.3.0

The vue-router version used in my project is 4.1.3

You can search for information about the corresponding NPM package on this website https://unpkg.com/

// vue.config.js
const HfexAutoExternalsPlugin = require('hfex-auto-externals-plugin')
const externalsConfig = [
    {
        name:'vue',
        exposedField:'Vue',
        packageLink:'https://unpkg.com/vue@3.3.0/dist/vue.runtime.global.prod.js'
    },
    {
        name:'vue-router',
        exposedField:'VueRouter',
        packageLink:'https://unpkg.com/vue-router@4.1.3/dist/vue-router.global.prod.js'
    }
]

module.exports = {
    configureWebpack:{
        plugins:[
             HfexAutoExternalsPlugin({
                externalsConfig:externalsConfig
             })
        ]
    }
}

effect

build your project

npm run build

before use hfex-auto-externals-plugin

The packaging volume rendering of the project is as follows

before build bundle

after use hfex-auto-externals-plugin

The packaging volume rendering of the project is as follows

after build bundle

after build net

after build sourse

Obviously, the volume of the packaged project has decreased significantly

// vite.config.ts
import { defineConfig } from 'vite'

import HfexAutoExternalsPlugin from 'hfex-auto-externals-plugin/vite'
const externalsConfig = [
    {
        name:'vue',
        exposedField:'Vue',
        packageLink:'https://unpkg.com/vue@3.3.0/dist/vue.runtime.global.prod.js'
    },
    {
        name:'vue-router',
        exposedField:'VueRouter',
        packageLink:'https://unpkg.com/vue-router@4.1.3/dist/vue-router.global.prod.js'
    }
]

export default defineConfig({
    plugins:[
             HfexAutoExternalsPlugin({
                externalsConfig:externalsConfig
            })
    ]
})

ts issue

ts issue

To be fixed, the temporary solution is//@ ts ignore

ts issue

effect

build your project

npm run build

before use hfex-auto-externals-plugin

The packaging volume rendering of the project is as follows

before build bundle

after use hfex-auto-externals-plugin

The packaging volume rendering of the project is as follows

after build bundle

after build net

after build sourse

Obviously, the volume of the packaged project has decreased significantly

parameter

PropTypeDefaultdescriptionrequired
externalsConfigArray<{name:string;exposedField:string;packageLink:string}>[]externalsConfigtrue

License

MIT.

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago