expose-webpack-module

1.0.3 • Public • Published

expose-webpack-module

An expose function implemented by AST (Syntax Abstract Tree) that modifies the webpack production code to return its running results.

image

install

npm i expose-webpack-module --save

example

./test/index.js

import expose from "expose-webpack-module"
const source = "some code like ./test/source.js"
const target = expose(source)

with inject-content-webpack-plugin

plugins: [
    new InjectPlugin({
        inject: expose
    })
]

Last but not least !!!

After reading the html-webpack-plugin source code, I learned to use LibraryTemplatePlugin to solve this problem

// webpack.config.js
plugins: [
    new LibraryTemplatePlugin('HTML_WEBPACK_PLUGIN_RESULT', 'var'),
    new InjectPlugin({
        inject: source => source.replace('var HTML_WEBPACK_PLUGIN_RESULT =', '')
    })
]

Package Sidebar

Install

npm i expose-webpack-module

Weekly Downloads

0

Version

1.0.3

License

ISC

Unpacked Size

16.3 kB

Total Files

20

Last publish

Collaborators

  • 15000621931