Skip to content

Instantly share code, notes, and snippets.

@maiha maiha/jquery.md
Last active Dec 12, 2018

Embed
What would you like to do?

merge multiple private libraies into one js

  • webpack-3.12.0

config

  entry: {
    'main.bundle.js': './src/assets/javascripts/main.js'
  },
  output: {
    filename: '[name]',
    path: path.resolve(__dirname, '../../public/dist'),
    publicPath: '/dist'
  },

private lib 1

function foo() {
}
module.exports = foo;

private lib 2

function bar() {
}
module.exports = bar;

main.js

import foo from './lib1.js'
import bar from './lib2.js'

if (!window.foo) { window.foo = foo; }
if (!window.bar) { window.bar = bar; }

consumer

<script src="/dist/main.bundle.js"></script>
<script>
  window.foo();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.