npm.io
1.0.4 • Published 7 years ago

non-module-bundler-plugin

Licence
ISC
Version
1.0.4
Deps
0
Size
5 kB
Vulns
0
Weekly
0
Stars
1

Non Module Bundler Plugin

This plugin will simply merge all your input js files into a single one.

Install

  npm i --save-dev non-module-bundler-plugin

Usage

Just add the plugin to your webpack config as follows:

webpack.config.js

const path = require('path');
const NonModuleBundlerPlugin = require('non-module-bundler-plugin')

module.exports = {
  entry: 'index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'index.js',
    compress: false
  },
  plugins: [
    new NonModuleBundlerPlugin({
            filename: 'libs.js',      // This is your output bundle name
            sourceFiles: [
                path.resolve(__dirname, './src/lib/script1.js'),       // paths to script files
                path.resolve(__dirname, './src/lib/script2.js'),
                path.resolve(__dirname, './src/script3.js'),
                path.resolve(__dirname, './src/lib/america_lib/script4.js'),
                path.resolve(__dirname, './src/lib/china_lib/script5.js')
            ]
        })
  ]
}

This will generate a file named libs.js in your build folder dist containing merged code of all your script files above. Set the option 'compress' to 'true' to compress and minify the result, by defaults it's 'false';