Beispiel #1
0
const config = (node, min) => ({
  input: node ? './src/main.js' : './src/svg.js',
  output: {
    file: node ? './dist/svg.node.js'
      : min ? './dist/svg.min.js'
        : './dist/svg.js',
    format: node ? 'cjs' : 'iife',
    name: 'SVG',
    sourcemap: true,
    banner: headerLong,
    // remove Object.freeze
    freeze: false
  },
  treeshake: {
    // property getter have no sideeffects
    propertyReadSideEffects: false
  },
  plugins: [
    resolve({ browser: !node }),
    commonjs(),
    getBabelConfig(node && 'maintained node versions'),
    filesize(),
    !min ? {} : uglify({
      mangle: {
        reserved: classes
      },
      output: {
        preamble: headerShort
      }
    })
  ]
})
const umdConfig = ({minify} = {}) => ({
  input: pkg.source,
  external: ['react', 'react-dom', 'prop-types'],
  output: {
    name: 'SortableHOC',
    file: minify ? pkg.browser.replace('.js', '.min.js') : pkg.browser,
    format: 'umd',
    globals: {
      react: 'React',
      'react-dom': 'ReactDOM',
      'prop-types': 'PropTypes',
    },
  },
  plugins: [
    resolve(),
    babel(
      babelConfig({
        targets: {browsers: ['last 2 versions', 'safari >= 7']},
      }),
    ),
    replace({
      'process.env.NODE_ENV': JSON.stringify(
        minify ? 'production' : 'development',
      ),
    }),
    commonjs(),
    minify && uglify(),
    filesize(),
  ],
});
Beispiel #3
0
function plugins (options = {}) {
  const plugins = [
    replace(options.replace),
    babel({
      runtimeHelpers: true,
      sourceMap: true,
      include: [
        'src/**/*',
      ],
    }),
    resolve({
      main: true,
      module: true,
      jsnext: true,
      browser: true,
    }),
    cjs(),
  ]
  if (options.min) {
    plugins.push(uglify({
      mangle: true,
      sourceMap: true,
      compress: {
        warnings: false,
      },
      output: {
        preamble: options.banner,
      },
    }))
  }
  return plugins
}
const nodeUmdRollupConfigFactory = (isProduction) => {
  const nodeRollupConfig = {
    input: `dist-esm/${outputName}.js`,
    output: {
      file: `dist/${outputName}.js`,
      banner: banner,
      format: "umd",
      name: "Microsoft.ApplicationInsights",
      sourcemap: true
    },
    plugins: [
      replace({
        delimiters: ["", ""],
        values: {
          "// Copyright (c) Microsoft Corporation. All rights reserved.": "",
          "// Licensed under the MIT License.": ""
        }
      }),
      nodeResolve()
    ]
  };

  if (isProduction) {
    nodeRollupConfig.output.file = `dist/${outputName}.min.js`;
    nodeRollupConfig.plugins.push(
      uglify({
        output: {
          preamble: banner
        }
      })
    );
  }

  return nodeRollupConfig;
};
function rollupPlugins(isUglified = false) {
  const plugins = [
    babel({
      exclude: 'node_modules/**',
    }),
    cleanup(),
  ]

  return isUglified ? plugins.concat(uglify()) : plugins
}
module.exports = function (env) {
    return [
        inject({
            include: '**/*.js',
            //exclude: 'node_modules/**',
            modules: {
                $: 'jquery',
                jQuery: 'jquery',
                moment: 'moment'
            }
        }),
        resolve({
            // use "module" field for ES6 module if possible
            mainFields: [
                // use "module" field for ES6 module if possible
                'module'
            ],

            // some package.json files have a `browser` field which
            // specifies alternative files to load for people bundling
            // for the browser. If that's you, use this option, otherwise
            // pkg.browser will be ignored
            browser: false  // Default: false
        }),
        json(),
        commonjs(),
        handlebars({
            handlebars: {
                options: {
                    sourceMap: env !== 'production' ? 'inline': false
                }
            },
            templateExtension: '.hbs'
        }),
        buble({
            objectAssign: 'Object.assign',
            transforms: {
                dangerousForOf: true
            }
        }),
        replace({
          'process.env.NODE_env': JSON.stringify(env)
        }),
        env === 'production' && uglify({
            compress: {
                dead_code: true,
                drop_console: true
            }
        }, minify)
    ];
};
const createConfig = ({ output, browser = false, umd = false, env } = {}) => {
  const min = env === 'production';

  return {
    input: 'src/index.js',
    output: ensureArray(output).map(format =>
      Object.assign({}, format, {
        name: 'TextareaAutosize',
        exports: 'named',
        globals: {
          react: 'React'
        }
      })
    ),
    plugins: [
      nodeResolve({
        jsnext: true
      }),
      babel({
        exclude: 'node_modules/**',
        runtimeHelpers: true,
        plugins: [
          [
            '@babel/transform-runtime',
            { useESModules: output.format !== 'cjs' }
          ]
        ]
      }),
      commonjs(),
      replace(
        Object.assign(
          env ? { 'process.env.NODE_ENV': JSON.stringify(env) } : {},
          {
            'process.env.BROWSER': JSON.stringify(browser)
          }
        )
      ),
      min &&
        uglify({
          compress: {
            pure_getters: true,
            unsafe: true,
            unsafe_comps: true,
            warnings: false
          }
        })
    ].filter(Boolean),
    external: makeExternalPredicate(umd ? external : allExternal)
  };
};
Beispiel #8
0
    bundle.bundleTypes.forEach(async (type) => {
        const filename = getFilename(bundle.name, type);
        const rollupOutputConfig = {
            dir: resolve(buildDir, type.format),
            format: type.format,
            file: filename,
            sourcemap: false,
            interop: false
        };
        const rollupInputConfig = {
            input: resolve(context, bundle.entry),
            plugins: [
                resolver(),
                replace({
                    __DEV__: type.asserts
                }),
                commonjs(),
                typescript({
                    tsconfigOverride: {
                        compilerOptions: {
                            declarationDir: resolve(buildDir, bundle.typings),
                            module: 'esnext',
                        }
                    },
                    useTsconfigDeclarationDir: false,
                    clean: true
                }),
                type.minify && uglify()
            ],
            external: bundle.externals
        };
        const bundleKey = `${chalk.white.bold(filename)}${chalk.dim(` (${type.format.toLowerCase()})`)}`;

        try {
            console.log(`${chalk.bgYellow.black(' BUILDING ')} ${bundleKey}`);
            const result = await rollup(rollupInputConfig);
            const writer = await result.write(rollupOutputConfig);
            console.log(`${chalk.bgGreen.black(' COMPLETE ')} ${bundleKey}`);
            if (type === BUNDLE_TYPES.NODE_PROD) {
                console.log(chalk.green(`@bem-react/${process.env.PKG} gzip size:`), execSync(`../../node_modules/.bin/gzip-size ${join(buildDir, type.format, filename)}`).toString());
            }
        }
        catch (error) {
            console.log(`${chalk.bgRed.black(' OH NOES! ')} ${bundleKey}`);
            throw error;
        }
    });
const getPlugins = ({minify = false} = {}) => [
  cpy({
    files: 'src/icons',
    dest: 'dist/uploadcare.tinymce/icons/',
    options: {verbose: true},
  }),
  license({
    banner: `
      <%= pkg.name %> <%= pkg.version %>
      <%= pkg.description %>
      <%= pkg.homepage %>
      Date: <%= moment().format('YYYY-MM-DD') %>
    `,
  }),
  jscc({values: {_WIDGET_VERSION: pkg.widgetVersion}}),
  minify && uglify(),
]
Beispiel #10
0
 return new _promise2.default(function (resolve, reject) {
   rollup.rollup({
     input: entry,
     plugins: plugins().concat([uglify({
       output: {
         // comments: 'all'
       }
     })])
   }).then(function (bundle) {
     bundle.write({
       format: 'umd',
       name: options.umdModuleName,
       banner: banner(),
       file: path.resolve(dist, options.projectName + '.umd.min.js'),
       sourceMap: false
     });
     resolve();
   });
 });
Beispiel #11
0
gulp.task('build', async function () {
    let bundle = await await rollup.rollup({
        input: resolve(src, 'js', 'index.js'),
        plugins: [
            babel({
                exclude: 'node_modules/**' // only transpile our source code
            }),
            uglify(),
            rollupResolve({
                jsnext: true,
                main: true,
                browser: true
            }),
            commonjs()
        ]
    })
    await bundle.write({
        file: resolve(dist, 'js', 'tinyJquery.min.js'),
        name: '$',
        format: 'umd'
    })
});
const browserRollupConfigFactory = isProduction => {
  const browserRollupConfig = {
    input: "dist-esm/applicationinsights-channel-js.js",
    output: {
      file: "browser/applicationinsights-channel-js.js",
      banner: banner,
      format: "umd",
      name: "Microsoft.ApplicationInsights",
      sourcemap: true
    },
    plugins: [
      replace({
        delimiters: ["", ""],
        values: {
          "// Copyright (c) Microsoft Corporation. All rights reserved.": "",
          "// Licensed under the MIT License.": ""
        }
      }),
      nodeResolve({
        browser: false,
        preferBuiltins: false
      })
    ]
  };

  if (isProduction) {
    browserRollupConfig.output.file = "browser/applicationinsights-channel-js.min.js";
    browserRollupConfig.plugins.push(
      uglify({
        output: {
          preamble: banner
        }
      })
    );
  }

  return browserRollupConfig;
};
const createConfig = ({ umd = false, output } = {}) => ({
  input: "src/index.js",
  output,
  external: [
    ...Object.keys(umd ? {} : pkg.dependencies || {}),
    ...Object.keys(pkg.peerDependencies || {})
  ],
  /**
   * suppress false warnings https://github.com/rollup/rollup-plugin-babel/issues/84
   */
  onwarn: () => null,
  plugins: [
    babel({ runtimeHelpers: true }),
    resolve(),
    commonjs({ extensions: [".js", ".jsx"] }),
    umd && uglify(),
    license({
      banner: {
        file: path.join(__dirname, "LICENSE")
      }
    })
  ].filter(Boolean)
});
function createConfig(entry, out, name) {
  return [
    {
      input: `./src/${entry}.js`,
      output: { file: `dist/${out}.js`, format: 'esm' },
      external,
      plugins: [babel(getBabelOptions({ useESModules: true })), sizeSnapshot()],
    },
    {
      input: `./src/${entry}.js`,
      output: { file: `dist/${out}.cjs.js`, format: 'cjs' },
      external,
      plugins: [babel(getBabelOptions({ useESModules: false }))],
    },
    ...(name
      ? [
          {
            input: `./src/${entry}.js`,
            output: {
              file: `dist/${out}.umd.js`,
              format: 'umd',
              name,
              globals,
            },
            external: Object.keys(globals),
            plugins: [
              resolve(),
              babel(getBabelOptions({ useESModules: true })),
              commonjs({ include: '**/node_modules/**' }),
              sizeSnapshot(),
              uglify(),
            ],
          },
        ]
      : []),
  ]
}
Beispiel #15
0
const build = ({ NODE_ENV, format, suffix }) => ({
  external: Object.keys(globals),
  input: 'src/fastener.js',
  output: {
    globals,
    name: 'F',
    format,
    file: `dist/fastener.${suffix}`
  },
  plugins: [
    NODE_ENV && replace({ 'process.env.NODE_ENV': JSON.stringify(NODE_ENV) }),
    nodeResolve({ modulesOnly: true }),
    babel(),
    NODE_ENV === 'production' &&
      uglify({
        compress: {
          hoist_funs: true,
          passes: 3,
          pure_getters: true,
          pure_funcs: ['require']
        }
      })
  ].filter(x => x)
})
Beispiel #16
0
import filesize from 'rollup-plugin-filesize'

export default [
  {
    input: './src/index.js',
    output: {
      file: 'modelz.js',
      exports: 'default',
      format: 'umd',
      name: 'modelz',
      sourcemap: true,
    },
    plugins: process.env.TEST ? [] : [buble(), filesize()],
  },
  {
    input: './src/index.js',
    output: {
      file: 'modelz.min.js',
      exports: 'default',
      format: 'umd',
      name: 'modelz',
      sourcemap: true,
    },
    plugins: [
      buble(),
      uglify.uglify({ mangle: true, compress: true }),
      filesize(),
    ],
  },
]
const { uglify } = require('rollup-plugin-uglify')
const packageJson = require('./package.json')

const baseConfig = require('./rollup.config.js')

baseConfig.plugins.push(uglify())
baseConfig.output.file = `dist/${packageJson.name}.min.js`

module.exports = baseConfig
import base from './rollup.config.base'
import { uglify } from 'rollup-plugin-uglify'
import { minify } from 'uglify-es'

const config = Object.assign({}, base, {
  output: {
    exports: 'named',
    name: 'VueVirtualScroller',
    file: 'dist/vue-virtual-scroller.min.js',
    format: 'iife',
  },
})

config.plugins.push(uglify({}, minify))

export default config
configMin.output.file = 'dist/vue-upload-component.min.js'
configMin.output.name = 'VueUploadComponent'
configMin.plugins.push(
  vue({
    style: {
      trim: true,
    },
    template: {
      isProduction: true,
    },
    css: true,
  }),
  babel(),
  uglify({
    output: {
      comments: /^!/,
    }
  })
)


let configPart = baseConfig()
configPart.input = 'src/index.js'
configPart.output.file = 'dist/vue-upload-component.part.js'
configPart.output.name = 'VueUploadComponent'
configPart.plugins.push(
  pluginCSS(),
  vue({
    style: {
      trim: true,
    },
export default [
    {
        input: './src/lib/Lib.ts',
        external: [ 'typescript-collections', 'sanctuary-type-classes'],
        output: [
          { file: "dist/sodium.umd.min.js", name: "Sodium", format: 'umd', sourcemap: true,
            globals: {
                'typescript-collections': 'Collections',
                'sanctuary-type-classes': 'Z'
            }
          },
        ],
        plugins: [
            replace({
                'process.env.NODE_ENV': JSON.stringify( process.env['NODE_ENV'] )
            }),

            typescript({
                tsconfigOverride: {
                    compilerOptions: {
                        declaration: false //will be run as a separate step via tsc which is more thorough
                    }
                },
                useTsconfigDeclarationDir: true,
            }),

            uglify({}, minify)
        ]
    }
];
   ],
 },
 {
   input: 'src/index.js',
   output: {
     name: 'mediumZoom',
     file: umdPath.replace('.min', ''),
     format: 'umd',
   },
   plugins: [
     ...sharedPlugins,
     uglify({
       compress: false,
       mangle: false,
       output: {
         beautify: true,
         indent_level: 2,
         preamble: banner,
       },
     }),
   ],
 },
 {
   input: 'src/index.js',
   output: {
     name: 'mediumZoom',
     file: umdPath,
     format: 'umd',
   },
   plugins: [
     ...sharedPlugins,
Beispiel #22
0
			format: 'umd',
			file: 'lib/SVGPathData.js',
			sourcemap: true,
      name: 'svgpathdata'
		},
		{
      format: 'es',
      sourcemap: true,
      file: 'lib/SVGPathData.module.js'
    },
  ],
  plugins: [
		typescriptPlugin({
			typescript
		}),
    uglify({}, uglifyEs)
  ],
  // onwarn: function (warning, warn) {
  //   // Suppress this error message... there are hundreds of them. Angular team says to ignore it.
  //   // https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
  //   if ('THIS_IS_UNDEFINED' === warning.code) return
  //   if ('CIRCULAR_DEPENDENCY' === warning.code) {
	// 		const m = warning.message.match(/^Circular dependency: (.*) -> .* -> .*$/)
	// 		if (m) {
	// 			const start = m[1]
	// 			if (start.match(/out[/\\]index.js|src[/\\]index.ts/)) {
	// 				// this is a loop of length three starting at the index file: don't warn
	// 				return
	// 			}
	// 		}
	// 	}
Beispiel #23
0
    input,
    output: { file: `cjs/${pkg.name}.js`, format: "cjs" },
    external,
    plugins: [
      babel({ exclude: /node_modules/ }),
      replace({ "process.env.NODE_ENV": JSON.stringify("development") })
    ]
  },
  {
    input,
    output: { file: `cjs/${pkg.name}.min.js`, format: "cjs" },
    external,
    plugins: [
      babel({ exclude: /node_modules/ }),
      replace({ "process.env.NODE_ENV": JSON.stringify("production") }),
      uglify()
    ]
  }
];

const esm = [
  {
    input,
    output: { file: `esm/${pkg.name}.js`, format: "esm" },
    external,
    plugins: [
      babel({
        exclude: /node_modules/,
        runtimeHelpers: true,
        plugins: [["@babel/transform-runtime", { useESModules: true }]]
      }),
Beispiel #24
0
import resolve from 'rollup-plugin-node-resolve';
import { uglify } from 'rollup-plugin-uglify';
import sourcemaps from 'rollup-plugin-sourcemaps';

export default {
    input : 'lib/index.js',
    external : "type-r",

    output : {
        file   : 'dist/index.js',
        format : 'umd',
        name   : 'localStorageIO',
        sourcemap: true,
        globals : {
            "type-r":"Nested"
        }
    },
    plugins: [
        resolve(), //for support of `import X from "directory"` rather than verbose `import X from "directory/index"`
        sourcemaps(),
        uglify()
    ]
};
Beispiel #25
0
  + '//  (c) 2013-' + new Date().getFullYear() + ' Scott Sauyet, Michael Hurley, and David Chambers\n'
  + '//  Ramda may be freely distributed under the MIT license.\n';

var input = 'source/index.js';

var config = {
  input: input,
  output: {
    format: 'umd',
    name: 'R',
    exports: 'named',
    banner: banner
  },
  plugins: []
};

if (process.env.NODE_ENV === 'production') {
  config.plugins.push(
    uglify({
      compress: {
        pure_getters: true,
        unsafe: true,
        unsafe_comps: true,
        warnings: false
      }
    })
  );
}

module.exports = config;
Beispiel #26
0
  external: [
    'prop-types',
    'react',
    'react-dom',
  ],

  plugins: [
    babel({
      exclude: 'node_modules/**'
    }),

    strip({
      debugger: true,

      functions: [
        'console.log', 'assert.*', 'debug', 'alert',
        '*.logger.verbose', '*.logger.debug', '*.logger.info'
      ]
    }),

    process.env.BABEL_ENV === "production" && uglify(),

    license({
      banner: {
        file: path.join(__dirname, 'LICENSE')
      }
    })
  ]
};
Beispiel #27
0
const fs = require("fs");
const basename = require("path").basename;

// constants
const isProduction = () => process.env.NODE_ENV === "production";
const pkg = require("./package.json");
const babelPlugin = babel({
	presets: [["@babel/env", {modules: false}]],
	babelrc: false
});
const replacePlugin = replace({
	delimiters: ["<%= ", " %>"],
	"build_version": pkg.version,
	"build_date": getDateString()
});
const uglifyPlugin = uglify();
let bundleCache;

// tasks
gulp.task("serve", () => {
	browser.init({
		server: {baseDir: "./"},
		options: {ignored: "./dev/**/*"}
	});
});

gulp.task("watch", () => {
	gulp.watch("./dev/src/**/*.js", gulp.series("js", browser.reload));
	gulp.watch("./index.html", gulp.series(browser.reload));
	gulp.watch("./dev/icons/*.svg", gulp.series("icons"));
	gulp.watch("./dev/inject/*", gulp.series("inject", browser.reload));
Beispiel #28
0
 * @type {Config}
 */
const UMDconfig = {
  ...CommonConfig,
  input: resolve(PATHS.entry.esm5, 'index.js'),
  output: {
    file: getOutputFileName(
      resolve(PATHS.bundles, 'index.umd.js'),
      ifProduction()
    ),
    format: 'umd',
    name: LIB_NAME,
    sourcemap: true,
  },
  plugins: removeEmpty(
    /** @type {Plugin[]} */ ([...plugins, ifProduction(uglify())])
  ),
}

/**
 * @type {Config}
 */
const FESMconfig = {
  ...CommonConfig,
  input: resolve(PATHS.entry.esm2015, 'index.js'),
  output: [
    {
      file: getOutputFileName(
        resolve(PATHS.bundles, 'index.esm.js'),
        ifProduction()
      ),
Beispiel #29
0
import buble from 'rollup-plugin-buble'
import { uglify } from 'rollup-plugin-uglify'

export default {
  input: 'src/carousel.js',
  output: {
    file: 'dist/carousel.js',
    format: 'cjs'
  },
  plugins: [ buble(), uglify() ],
  external: ['react', 'react-dom', 'prop-types']
}
  protoToAssign()
];
const minifiedPlugins = [
  ...plugins,
  replace({
    'process.env.NODE_ENV': '"production"'
  }),
  babel({
    babelrc: false,
    plugins: [
      'babel-plugin-minify-dead-code-elimination'
    ]
  }),
  uglify({
    compress: { warnings: false, ie8: true },
    mangle: { ie8: true },
    output: { ie8: true }
  })
];

export default [
  {
    input,
    output: {
      file: 'dist/react-input-mask.js',
      format: 'umd',
      name: 'ReactInputMask',
      globals: { 'react': 'React', 'react-dom': 'ReactDOM' }
    },
    external,
    plugins: [