gulp.task('scripts:app', function () {
  return rollup({
    entry: 'src/app/App.js',
    plugins: [
      // compile future ES 2015 to runnable ES 5
      rollupBabel({
        runtimeHelpers: true,
        // don't compile templates
        exclude: 'src/app/templates/**'
      }),
      // load templates from files
      rollupString({
        include: ['**/*.html']
      }),
      // minify output
      rollupUglify()
    ]
  }).then(function (bundle) {
    return bundle.write({
      // include sourcemaps to ES2015 files
      sourceMap: true,
      // Dojo friendly output options
      format: 'amd',
      useStrict: false,
      dest: 'dist/app/App.min.js'
    });
  });
});
function _js() {
    return gulp.src(["./src/pages/*/*.js", "!./src/pages/*/_*.js"], { read: false })
        .pipe(plumber(options.plumber("Js")))
        .pipe(rollup({
            sourceMap: true,
            format: "iife",
            plugins: [
                eslint({
                    envs: ["browser", "node", "es6"],
                    fix: true,
                    parser: "babel-eslint"
                }),
                nodeResolve({
                    browser: true,
                    extensions: [ '.js', '.json' ],
                    preferBuiltins: false
                }),
                commonjs(),
                buble(),
                uglify()
            ]
        }))
        .pipe(sourcemaps.write("."))
        .pipe(flatten())
        .pipe(gulp.dest("./build/"))
}
Example #3
0
gulp.task('build:vendor:modernizr', () => {
	const { header, modernizr, rename, sourcemaps, uglify } = gulpPlugins;

	return gulp.src([`${project.sass}/**/*.scss`, `${project.js}/**/*.js`])
		.pipe(modernizr({
			options: [
				'setClasses',
				'addTest',
				'html5printshiv',
				'testProp',
				'fnBind'
			]
		}))
		.pipe(gulp.dest(`${project.vendor}/modernizr`))

		// minified version
		.pipe(sourcemaps.init())
		.pipe(rename({ suffix: '.min' }))
		.pipe(uglify({
			preserveComments: 'license'
		}))
		.pipe(header(banner))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest(`${project.vendor}/modernizr`));
});
Example #4
0
function build({main, src, outFile, dist, format, intro, minify = false}) {
  let mainPath = `${src}/${main}.ts`;

  let rollupOptions = {
    format, intro,
    entry: mainPath,
    moduleName: _.capitalize(_.camelCase(main)),
    sourceMap: true,
    plugins: [
      typescript({
        typescript: require("typescript"),
        include: `**/*.ts`
      })
    ]
  };

  if (minify) {
    rollupOptions.plugins.push(uglify());
  }

  // TODO: room for improvements?
  return new Promise((resolve, reject) =>
    rollup(rollupOptions)
      .pipe(source(mainPath))
      .pipe(buffer())
      .pipe(sourcemaps.init({loadMaps: true}))
      .pipe(rename(outFile || `${main}.${format}${minify ? ".min" : ""}.js`))
      .pipe(sourcemaps.write("."))
      .pipe(gulp.dest(dist))
      .on("error", reject)
      .on("end", resolve));
}
Example #5
0
function getPlugins(
  entry,
  babelOpts,
  paths,
  filename,
  bundleType,
  isRenderer,
  manglePropertiesOnProd
) {
  const plugins = [
    replace(Modules.getDefaultReplaceModules(bundleType)),
    babel(updateBabelConfig(babelOpts, bundleType)),
    alias(
      Modules.getAliases(paths, bundleType, isRenderer, argv.extractErrors)
    ),
  ];
  switch (bundleType) {
    case UMD_DEV:
    case NODE_DEV:
    case FB_DEV:
    case RN_DEV:
      plugins.push(
        replace(stripEnvVariables(false)),
        // needs to happen after strip env
        commonjs(getCommonJsConfig(bundleType))
      );
      break;
    case UMD_PROD:
    case NODE_PROD:
    case FB_PROD:
    case RN_PROD:
      plugins.push(
        replace(stripEnvVariables(true)),
        // needs to happen after strip env
        commonjs(getCommonJsConfig(bundleType)),
        uglify(
          uglifyConfig(
            bundleType !== FB_PROD,
            manglePropertiesOnProd,
            bundleType === UMD_PROD
          )
        )
      );
      break;
  }
  // this needs to come last or it doesn't report sizes correctly
  plugins.push(
    sizes({
      getSize: (size, gzip) => {
        const key = `${filename} (${bundleType})`;
        Stats.currentBuildResults.bundleSizes[key] = {
          size,
          gzip,
        };
      },
    })
  );

  return plugins;
}
Example #6
0
 plugins.forEach(item => {
   build({
     input: 'src/plugins/' + item.input,
     output: 'plugins/' + item.name + '.min.js',
     plugins: [uglify()]
   })
 })
module.exports = (input, banner, intro) =>
	rollup
		.rollup({
			input: input,
			plugins: [
				typescript(),
				uglify({
					mangle: false,
					output: {
						comments: 'some'
					}
				})
			]
		})
		.then(bundle => bundle
			.write({
				name: 'justcore',
				format: 'umd',
				banner: banner,
				intro: intro,
				file: 'dist/justcore.umd.min.js',
				exports: 'named'
			})
			.then(() => console.info('PROD UMD bundled successfully'))
		);
const rollupPluginFactory = async () =>  {
  const vue = await vueWarpper()
  return [  // resolve
  aliasPlugin({
    resolve: ['.js', '.json', '/index.js', '.css', '.vue', '.svg'], // @TODO '/index.js' hack
    'mand-mobile/components': resolve('components'),
    'mand-mobile/lib': resolve('lib'),
    'mand-mobile': resolve('components'),
    '@examples/assets/images/bank-zs.svg': resolve('examples/assets/images/bank-zs.svg'),
    '@examples/assets/images/tip-package.svg': resolve('examples/assets/images/tip-package.svg')
  }),
  nodeResolvePlugin({
    extensions: [ '.js', '.json', '.vue' ],
  }),

  common({
    include: 'node_modules/**',
  }),

  // inject
  replacePlugin({
    'process.env.NODE_ENV': `"${process.env.NODE_ENV}"`,
    'MAN_VERSION': `"${pkg.version}"`
  }),
  svgSpritePlugin(),
  // resource
  urlPlugin({
    limit: 10 * 1024,
  }),
  jsonPlugin(),
  ...vue,
  stylusCompilerPlugin({
    fn: stylusMixin,
  }),
  postcss({
    config: {
      path: resolve('postcss.config.js')
    }
  }),
  babel(babelrc({
    addModuleOptions: false,
    findRollupPresets: true,
    addExternalHelpersPlugin: false,
  })),

  // dest
  uglify({
    compress: {},
  }),
  fillHtmlPlugin({
    template: resolve('examples/index.html'),
    // publicPath: '/mand-mobile/examples/',
    publicPath: '/mand-mobile/examples/',
    destFile: path.resolve(EXAMPLE_OUTPUT_DIR, 'index.html')
  }),
  // cli
  progress(),
  filesize(),
]}
Example #9
0
].forEach((opts) => build({
    input: './src/index.ts',
    plugins: [
      typescript({
        tsconfig: './tsconfig.browser.json'
      }),
      opts.file.endsWith('min.js') ? uglify() : {}
    ]
  }, opts).then(() => console.log(`bundled: ${opts.file}`))
Example #10
0
				.then(() => rollup.rollup({
					entry: path,
					external: Object.keys(globals),
					onwarn: (msg) => log(`${fileName}.min.js`, msg),
					plugins: [
						es2015(),
						uglify()
					]
				}))
Example #11
0
const buildUmd = ({ env }) => ({
  input,
  external,
  output: {
    name: 'Formik',
    format: 'umd',
    sourcemap: true,
    file:
      env === 'production'
        ? `./dist/formik.umd.${env}.js`
        : `./dist/formik.umd.${env}.js`,
    exports: 'named',
    globals: {
      react: 'React',
      'react-native': 'ReactNative',
    },
  },

  plugins: [
    resolve(),
    replace({
      exclude: 'node_modules/**',
      'process.env.NODE_ENV': JSON.stringify(env),
    }),
    commonjs({
      include: /node_modules/,
      namedExports: {
        'node_modules/prop-types/index.js': [
          'object',
          'oneOfType',
          'string',
          'node',
          'func',
          'bool',
          'element',
        ],
      },
    }),
    sourceMaps(),
    env === 'production' && filesize(),
    env === 'production' &&
      uglify({
        output: { comments: false },
        compress: {
          keep_infinity: true,
          pure_getters: true,
        },
        warnings: true,
        ecma: 5,
        toplevel: false,
      }),
  ],
});
Example #12
0
gulp.task('bundle', () => {
    const globals = {
        // Angular dependencies
        '@angular/core': 'ng.core',
        '@angular/common': 'ng.common',
        '@angular/http': 'ng.http',

        // Rxjs dependencies
        'rxjs/Subject': 'Rx',
        'rxjs/add/observable/fromEvent': 'Rx.Observable',
        'rxjs/add/observable/forkJoin': 'Rx.Observable',
        'rxjs/add/observable/of': 'Rx.Observable',
        'rxjs/add/observable/merge': 'Rx.Observable',
        'rxjs/add/observable/throw': 'Rx.Observable',
        'rxjs/add/operator/auditTime': 'Rx.Observable.prototype',
        'rxjs/add/operator/toPromise': 'Rx.Observable.prototype',
        'rxjs/add/operator/map': 'Rx.Observable.prototype',
        'rxjs/add/operator/filter': 'Rx.Observable.prototype',
        'rxjs/add/operator/do': 'Rx.Observable.prototype',
        'rxjs/add/operator/share': 'Rx.Observable.prototype',
        'rxjs/add/operator/finally': 'Rx.Observable.prototype',
        'rxjs/add/operator/catch': 'Rx.Observable.prototype',
        'rxjs/add/observable/empty': 'Rx.Observable.prototype',
        'rxjs/add/operator/first': 'Rx.Observable.prototype',
        'rxjs/add/operator/startWith': 'Rx.Observable.prototype',
        'rxjs/add/operator/switchMap': 'Rx.Observable.prototype',
        'rxjs/Observable': 'Rx'
    };

    const rollupOptions = {
        context: 'this',
        external: Object.keys(globals),
        plugins: [
            rollupNodeResolve({ module: true }),
            rollupUglify()
        ]
    };

    const rollupGenerateOptions = {
        // Keep the moduleId empty because we don't want to force developers to a specific moduleId.
        moduleId: '',
        moduleName: 'ngxForms', //require for 'umd' bundling, must be a valid js identifier, see rollup/rollup/issues/584
        format: 'umd',
        globals,
        dest: 'ngx-forms.umd.js'
    };

    return gulp.src(`${config.outputDir}/index.js`)
        .pipe(gulpRollup(rollupOptions, rollupGenerateOptions))
        .pipe(gulp.dest(`${config.outputDir}/bundles`));
});
Example #13
0
export default async function buildWeb() {
  const start = new Date();
  console.log('Running rollup...');
  await rollup({
    rollup: {
      entry: path.join(process.cwd(), config.root, 'es6', 'index.js'),
      plugins: [
        commonjs({
          include: [`${__dirname}/../node_modules/**`, 'node_modules/**'],
          sourceMap: false,
        }),
        builtins(),
        nodeGlobals(),
        nodeResolve({
          jsNext: true,
          main: true,
          browser: true,
        }),
        bundleBabel({
          main: true,
          jsNext: true,
        }),
        babel({
          exclude: ['node_modules/babel-runtime/**', 'node_modules/core-js/**'],
          presets: [[
            'es2015',
            {
              modules: false,
            },
          ], 'stage-0', 'react'],
          plugins: ['transform-runtime', 'external-helpers'],
          runtimeHelpers: true,
        }),
        json(),
        replace({
          'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
        }),
        config.uglify ? uglify() : undefined,
      ].filter(x => x != null),
      onwarn: Function.prototype,
    },
    bundle: {
      format: 'umd',
      dest: path.join(process.cwd(), 'bin', 'index.js'),
      moduleId: npmPackage.name,
      moduleName: config.global || npmPackage.name,
    },
  });
  console.log(`Build finished in ${(new Date() - start) / 1000} seconds.`);
}
Example #14
0
const buildCore = function() {
  build({
    input: 'src/core/index.js',
    output: 'docsify.js'
  })

  if (isProd) {
    build({
      input: 'src/core/index.js',
      output: 'docsify.min.js',
      plugins: [uglify()]
    })
  }
}
        function getOptions(minify) {

            return {

                context: "this",
                external: Object.keys(globals),
                plugins: minify ? [
                        uglify({
                            output: {
                                comments: (node, comment) => comment.value.startsWith("!")
                            }
                        })
                    ] : []
            };
        }
Example #16
0
function plugins(production) {
    let plugins = [
        resolve(),
        commonjs()
    ];
    if (production) {
        plugins.push(uglify({
            compress: {
                global_defs: {
                    __DEV__: true
                }
            }
        }));
    }
    return plugins;
}
Example #17
0
 .then(() => build({
   dest: 'dist/wilderness-core.production.js',
   entry: 'src/index.js',
   format: 'umd',
   plugins: [
     babel({
       exclude: 'node_modules/**',
       plugins: [ 'transform-object-rest-spread' ],
       presets: [[ 'es2015', { 'modules': false } ]]
     }),
     commonJs(),
     resolve({ module: true }),
     replace({ '__DEV__': false }),
     uglify()
   ]
 }))
Example #18
0
function build(format) {
  const defaultPlugins = [
    license({
      banner:
        '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
        '<%= moment().format("YYYY-MM-DD") + "\\n" %>' +
        '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
        '* Copyright (c) <%= moment().format("YYYY") %> <%= pkg.author.name %>;' +
        ' Licensed <%= _.map(pkg.licenses, "type").join(", ") %> */\n\n'
    }),
    babel({
      babelrc: false,
      presets: [
        [
          'env',
          {
            modules: false
          }
        ],
        'stage-0'
      ]
    }),
    filesize()
  ]

  const plugins =
    format === 'min' ?
      defaultPlugins.concat(
          uglify({
            output: {
              comments: true
            }
          })
        ) :
      defaultPlugins

  return rollup({
    input: 'src/lozad.js',
    plugins
  }).then(bundle =>
    bundle.write({
      file: targets[format],
      format: format === 'min' ? 'umd' : format,
      name: 'lozad'
    })
  )
}
Example #19
0
 .then(() => rollup(addPlugins(config, [
   replace({
     'process.env.NODE_ENV': JSON.stringify('production')
   }),
   uglify({
     output: {
       comments: function(node, comment) {
         const text = comment.value;
         const type = comment.type;
         if (type == "comment2") {
           // multiline comment
           return /@preserve|@license|@cc_on/i.test(text);
         }
       }
     }
   })
 ])))
Example #20
0
 promise = promise.then(() => rollup.rollup({
   entry: `src/${file.name}.js`,
   external: Object.keys(pkg.dependencies).concat(Object.keys(pkg.peerDependencies)),
   plugins: [
     babel(Object.assign(pkg.babel, {
       babelrc: false,
       exclude: 'node_modules/**',
       runtimeHelpers: true,
       presets: file.presets,
       plugins: file.plugins,
     })),
   ].concat(file.minify ? [uglify()] : []),
 }).then(bundle => bundle.write({
   dest: `build/${file.output || file.name}${file.ext}`,
   format: file.format,
   sourceMap: !file.minify,
   moduleName: file.moduleName,
 })));
Example #21
0
gulp.task('compile-app-production', ['compress-external-modules'], () => {
  return gulp
    .src(`${APP_ROOT}js/*.js`)
    .pipe(
      rollup({
        sourceMap: true,
        format: 'amd',
        external: ['components/react', 'components/react-dom'],
        plugins: [
          rollupBabelPlugin(),
          rollupUglifyPlugin({ sourceMap: true }, uglifyjs.minifier),
          rollupIncludePathsPlugin({ extensions: ['.js', '.jsx'] }),
        ],
      })
    )
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(`${DIST_APP_ROOT}js`));
});
Example #22
0
export const plugins = () => [
    flow(),
    minifyStyleSpec(),
    json(),
    glsl('./src/shaders/*.glsl', production),
    buble({transforms: {dangerousForOf: true}, objectAssign: "Object.assign"}),
    production ? unassert() : false,
    resolve({
        browser: true,
        preferBuiltins: false
    }),
    commonjs({
        // global keyword handling causes Webpack compatibility issues, so we disabled it:
        // https://github.com/mapbox/mapbox-gl-js/pull/6956
        ignoreGlobal: true
    }),
    minified ? uglify() : false
].filter(Boolean);
Example #23
0
 entries.map(config => {
   console.log(chalk.yellow(`Starting build for ${config.name}...`));
   const plugins = [
     resolve({
       browser: true,
       preferBuiltins: false,
     }),
     json(),
     commonJs(),
     babel({
       exclude: 'node_modules/**',
       presets: ['es2015-rollup'],
     }),
   ];
   if (config.minify) {
     plugins.push(uglify());
   }
   return rollup
     .rollup({
       entry: 'lib/index.js',
       treeshake: true,
       plugins,
     })
     .then(bundle => {
       console.log(chalk.green(`${config.name} successfully rolled.`));
       console.log(chalk.yellow(`Starting write for ${config.name}...`));
       return bundle.write({
         format: 'umd',
         dest: config.dest,
         // Inject the version here because the JSON plugin here pulls everything in and freezes it, thus adding a lot of bloat.
         // intro: `global.VERSION = '${pkg.version}';`,
         sourceMap: config.minify ? 'inline' : false,
         moduleName: 'stardogjs',
       });
     })
     .then(() =>
       console.log(
         chalk.green(
           `${config.name} successfully written to ${config.dest}.`
         )
       )
     );
 })
const roll = (entry, dest) => {
  let env = 'development';
  if (production) {
    env = 'production';
  }

  return rollup({
    entry,
    plugins: [
      multiEntry(),
      buble(),
      nodeResolve({
        browser: true,
        main: true,
        jsnext: true,
      }),
      commonjs({
        include: [
          'node_modules/**',
          `${config.base.src}/**`,
        ],
      }),
      json(),
      replace({
        'process.env.NODE_ENV': JSON.stringify(env),
      }),
      production ? uglify({}, minify) : '',
    ],
  }).then((bundle) => {
    bundle.write({
      format: 'iife',
      moduleName: 'BarebonesBundle',
      sourceMap: !production,
      dest,
    });
  }).catch((err) => {
    notification('Failed to compile scripts. 😱', 'error');
    log(err.stack);
    error = true;
  });
};
function bundle(format) {
  return rollup({
    entry: entryFileName,
    sourceMap: true,
    banner: fs.readFileSync('./conf/license_header.txt'),
    plugins: [
      env.min === 'true' ? uglify({
          output: { comments: /@license/ },
          compress: { keep_fargs: false }
      }) : {},
      babel({
        exclude: 'node_modules/**',
        plugins: env.NODE_ENV ?
          ['transform-inline-environment-variables'] :
          []
      })
    ],
    format: format,
    moduleName: 'IncrementalDOM',
  });
}
Example #26
0
 promise = promise.then(() => rollup.rollup({
   entry: 'src/main.js',
   external: file.format === 'umd' ? [] : Object.keys(pkg.dependencies),
   plugins: [
     ...file.format === 'umd' ? [nodeResolve({ browser: true }), commonjs()] : [],
     babel({
       babelrc: false,
       exclude: 'node_modules/**',
       runtimeHelpers: true,
       presets: file.presets,
       plugins: file.plugins,
     }),
     ...file.minify ? [uglify()] : [],
   ],
 }).then(bundle => bundle.write({
   dest: `build/${file.output || 'main'}${file.ext}`,
   format: file.format,
   sourceMap: !file.minify,
   exports: 'named',
   moduleName: file.moduleName,
 })));
Example #27
0
const getPlugins = (env) => {
  const plugins = [
    resolve()
  ]

  if (env) {
    plugins.push(
      replace({
        'process.env.NODE_ENV': JSON.stringify(env)
      })
    )
  }

  plugins.push(
    babel({
      exclude: 'node_modules/**',
      babelrc: false,
      presets: [
        [ 'es2015', { loose: true, modules: false } ],
        'stage-1',
        'react'
      ],
      plugins: [ 'external-helpers' ].concat(
        env === 'production'
          ? [ 'dev-expression', 'transform-react-remove-prop-types' ]
          : []
      )
    }),
    commonjs({
      include: /node_modules/
    })
  )

  if (env === 'production') {
    plugins.push(uglify())
  }

  return plugins
}
Example #28
0
function writeUMDFile(filename, module) {
    const lang = p.basename(filename, '.js');

    return rollup({
        entry: {
            path: filename,
            contents: module,
        },
        plugins: [
            memory(),
            uglify(),
        ],
    })
    .then((bundle) => {
        return bundle.write({
            dest      : filename,
            format    : 'umd',
            moduleName: `ReactIntlLocaleData.${lang}`,
        });
    })
    .then(() => filename);
}
Example #29
0
function getPlugins({min, lang, sourcemap, removeDev, addBundleVersion}) {
    let plugins = [];

    removeDev && plugins.push(
        ecRemoveDevPlugin({sourcemap})
    );

    lang && plugins.push(
        ecLangPlugin({lang})
    );

    plugins.push(
        nodeResolvePlugin()
    );

    addBundleVersion && plugins.push({
        outro: function () {
            return 'exports.bundleVersion = \'' + (+new Date()) + '\';';
        }
    });

    min && plugins.push(uglifyPlugin({
        compress: {
            // Eliminate __DEV__ code.
            // Currently, in uglify:
            // `var vx; if(vx) {...}` can not be removed.
            // `if (__DEV__) {...}` can be removed if `__DEV__` is defined as `false` in `global_defs`.
            // 'global_defs': {
            //     __DEV__: false
            // },
            'dead_code': true
        },
        output: {
            preamble: preamble.js
        }
    }));

    return plugins;
}
Example #30
0
function createConfig(entry, out, name) {
  return [
    {
      input: `./src/${entry}.js`,
      output: { file: `dist/${out}.es.js`, format: 'es' },
      external: isExternal,
      plugins: [babel(getBabelOptions({ useESModules: true })), sizeSnapshot()],
    },
    {
      input: `./src/${entry}.js`,
      output: { file: `dist/${out}.cjs.js`, format: 'cjs' },
      external: isExternal,
      plugins: [babel(getBabelOptions({ useESModules: false }))],
    },
    {
      input: `./src/${entry}.js`,
      output: {
        file: `dist/${out}.umd.js`,
        format: 'umd',
        name,
        globals: {
          react: 'React',
          'react-dom': 'ReactDOM',
          'prop-types': 'PropTypes',
          'react-spring': 'ReactSpring',
        },
      },
      external: ['react', 'react-dom', 'prop-types', 'react-spring'],
      plugins: [
        babel(getBabelOptions({ useESModules: false })),
        resolve(),
        commonjs(),
        sizeSnapshot(),
        uglify({ compress: true, mangle: { toplevel: true } }),
      ],
    },
  ]
}