Skip to content

mohasinsutar/rollup-webapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Roll up Starter app for web

Sample project to bundle your js in IIFE format and use it in browser.

Building js project

yarn install
yarn run build

This will package your js files from src folder and put it in dist.

Running project

In Development Mode with http-server and rollup watch support

yarn run dev

For Production

yarn run build

Rollup Config file

export default {
  input: 'src/main.js',
  output: {
    file: 'dist/bundle.js',
    format: 'iife',
    name: 'mybundle',
    sourcemap: true,
  },
  plugins: [
    commonjs(),
    resolve(),
    babel({
      exclude: 'node_modules/**' // only transpile our source code
    })
  ]
};

If you put following declaration in rollup.config.js then faker will be treated as external and will not be loaded with your library

external: ['faker']

Usage in browser script tags

IIFE bundle will be available with name mybundle and used as follows in index.html

<script src="bundle.js"></script>
<script type="text/javascript">
    function foo(){
        mybundle.sayHello();
    }
    function bar(){
        mybundle.sayHi();
    }
    function print(){
        document.getElementById('result').innerHTML = mybundle.printDemo();
    }
</script>

About

Rollup startup project for browser

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published