rollup-plugin-terser#terser JavaScript Examples

The following examples show how to use rollup-plugin-terser#terser. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: rollup.config.js    From vue-rough-notation with MIT License 6 votes vote down vote up
function getConfig ({
  file,
  format,
}) {
  return {
    input: path.resolve(__dirname, 'src/index.js'),
    output: {
      file,
      name: 'VueRoughNotation',
      format,
    },
    plugins: [
      resolve(),
      commonjs(),
      babel({
        babelHelpers: 'runtime',
        plugins: ['@babel/plugin-transform-runtime'],
      }),
      production && terser(),
    ],
  };
}
Example #2
Source File: rollup.config.js    From skills-client with Apache License 2.0 6 votes vote down vote up
module.exports = {
  input: 'src/index.js',
  output: {
    // need to pass in format, file (and name if format == umd) via cmd line
    sourcemap: true,
  },
  preserveSymlinks: true,
  plugins: [
    eslint(),
    babel({
      runtimeHelpers: true,
      exclude: 'node_modules/**',
    }),
    resolve({
      browser: true,
    }),
    replace({
      'process.env.NODE_ENV': JSON.stringify('production'),
      __skillsClientVersion__: `${pkg.name}-${pkg.version}`,
    }),
    commonjs(),
    terser(), // comment out to remove minimization
  ],
};
Example #3
Source File: rollup.config.js    From wx-updata with MIT License 6 votes vote down vote up
plugins = [
  json(),
  babel({
    exclude: 'node_modules/**',
  }),
  nodeResolve(), // 告诉 Rollup 如何查找外部模块
  commonjs(), // 将 CommonJS 转换成 ES2015 模块
  terser(), // 压缩文件
]
Example #4
Source File: rollup.config.js    From vue-iClient3D_for_Cesium with Apache License 2.0 6 votes vote down vote up
function liblist(libName, libSrc, type) {  //打包lib按需加载js库
    let format = 'es';
    if (type) {
        format = type
    }
    return {
        input: libSrc,
        output: {
            file: `lib/${libName}.js`,
            format: format
        },
        plugins: [
            scss({ include: /\.scss$/, sass: dartSass }), // 对所有样式文件进行编译
            vue(),
            babel(),
            image(),
            terser()
        ]
    }
}
Example #5
Source File: rollup.config.js    From svelte with MIT License 6 votes vote down vote up
plugins = [
    postcss({
        extract: 'ax.css',
        sourceMap: true
    }),
    sourcemaps(),
    resolve(),
    babel({
        babelrc: false,
        babelHelpers: 'bundled',
        exclude: 'node_modules/**',
        presets: [["@babel/env", {targets: {ie: 11}}]]
    }),
    terser({
        output: {comments: keepBanner}
    })
]
Example #6
Source File: rollup.node.config.js    From shell with MIT License 6 votes vote down vote up
plugins = [
  build.only('node'),
  build.applyVersion(build.version),
  babel({
    presets: [['@babel/preset-env', { targets: { node: true } }]],
    plugins: [
      ['@babel/plugin-proposal-class-properties', { loose: false }],
      ['@babel/plugin-proposal-private-methods', { loose: false }]
    ]
  }),
  terser(terserCfg)
]
Example #7
Source File: rollup.config.js    From aws-ssm-session with MIT License 6 votes vote down vote up
function chunk(input, name) {
  return {
    input: `dist/esm-browser/${input}.js`,
    output: {
      file: `dist/umd/${name}.min.js`,
      format: 'umd',
      name,
      compact: true,
    },
    plugins: [nodeResolve({ browser: true }), terser()],
  };
}
Example #8
Source File: rollup.config.js    From Lambda with MIT License 6 votes vote down vote up
productionConfig = {
  input: 'src/index.js',
  output: {
    file: 'dist/react-tabs.production.min.js',
    format: 'umd',
    name: 'ReactTabs',
    globals: {
      react: 'React',
    },
    sourcemap: true,
  },
  plugins: [
    ignore(['prop-types']),
    commonjs({ exclude: 'src/**' }),
    nodeResolve(),
    babel({ plugins: ['transform-react-remove-prop-types'] }),
    replace({
      'process.env.NODE_ENV': JSON.stringify('production'),
    }),
    terser(),
  ],
  external: ['react'],
}
Example #9
Source File: rollup.config.js    From sdk with MIT License 6 votes vote down vote up
export default async function() {
  return [{
    plugins: [
      multiInput(),
      json(),
      terser(),
      commonjs(),
      // Temporarily disabled, not sure if required
      // since rify is a node module doesnt seem to work
      // but would be nice to try embed it
      // wasm({
      //   sync: ['*.wasm'],
      // }),
    ],
    input: ['src/**/*.js'],
    output: [
      {
        dir: 'dist',
        format: 'esm',
        entryFileNames: '[name].js'
      },
      {
        dir: 'dist',
        format: 'cjs',
        entryFileNames: '[name].cjs'
      }
    ]
  }];
}
Example #10
Source File: rollup.config.js    From web-performance-monitor with MIT License 6 votes vote down vote up
minimize = (obj) => {
  const minObj = cloneDeep(obj)
  minObj.file = minObj.file.slice(0, minObj.file.lastIndexOf('.js')) + '.min.js'
  minObj.plugins = [
    terser({
      compress: { drop_console: !isDev },
      format: {
        comments: RegExp(`${pkg.name}`)
      }
    })
  ]
  minObj.banner = banner
  return minObj
}
Example #11
Source File: rollup.config.browser.js    From whatsapp-api-client with MIT License 6 votes vote down vote up
module.exports = {
  input: "src/index.js",
  output: [
    {
      file: "lib/whatsapp-api-client.min.js",
      format: "umd",
      exports: "default",
      name: "whatsAppClient",
      plugins: [terser()],
      globals: {
        fs: "fs",
        axios: "axios",
      },
    },
  ],
  plugins: [
    progress({
      clearLine: true,
    }),
    resolve({
      browser: true,
    }),
    commonJS({
      include: "node_modules/**",
    }),
    pluginJson(),
  ],
  external: ["fs"],
};
Example #12
Source File: rollup.config.js    From reoverlay with MIT License 6 votes vote down vote up
config = {
  input: 'src/index.js',
  output: {
    file: 'lib/index.js',
    format: 'cjs',
    exports: 'named',
  },
  external: ['react', 'react-dom'],
  plugins: [
    resolve({
      browser: true,
    }),
    babel({
      exclude: /node_modules/,
    }),
    commonjs(),
    copy({
      targets: [{ src: 'src/ModalWrapper.css', dest: 'lib' }],
    }),
    terser(),
  ],
}
Example #13
Source File: rollup.config.js    From cf-download-proxy with GNU General Public License v3.0 6 votes vote down vote up
config = {
  input: 'src/index.ts',
  output: {
    file: packageInfo.main,
    format: 'iife',
  },
  plugins: [
    resolve(),
    commonjs(),
    inject({
      require: ['node-mock', 'require'],
    }),
    alias({
      entries: {
        'node-mock': path.resolve(__dirname, '../src/libs/node-mock.ts'),
        'http': path.resolve(__dirname, '../src/libs/node-mock.ts'),
      }
    }),
    rawContentPlugin({
      include: ['**.css', '**.txt'],
    }),
    typescript(),
    etaPlugin({
      templatesDir: path.resolve(__dirname, '../src/templates'),
    }),
    terser({
      format: {
        comments: false
      }
    })
  ],
}
Example #14
Source File: rollup.config.js    From absurd-sql with MIT License 6 votes vote down vote up
function getConfig(entry, filename, perf) {
  // Remove the extension
  let basename = filename.replace(/\.[^.]*/, '');

  return {
    input: entry,
    output: {
      dir: perf ? 'dist/perf' : 'dist',
      entryFileNames: filename,
      chunkFileNames: `${basename}-[name]-[hash].js`,
      format: 'esm',
      exports: 'named'
    },
    plugins: [
      !perf &&
        alias({
          entries: {
            'perf-deets': path.resolve(
              __dirname,
              './node_modules/perf-deets/noop.js'
            )
          }
        }),
      webWorkerLoader({
        pattern: /.*\/worker\.js/,
        targetPlatform: 'browser',
        external: [],
        plugins: [terser()]
      }),
      nodeResolve()
    ],
    ...(perf ? { external: ['perf-deets'] } : {})
  };
}
Example #15
Source File: rollup.config.js    From vue3-json-editor with ISC License 6 votes vote down vote up
function createEntry (config) {
  const c = {
    external: ['vue'],
    input: 'components/index.ts',
    plugins: [],
    output: {
      file: config.outFile,
      format: config.format,
      globals: {
        vue: 'Vue'
      },
      exports: 'named'
    },
    onwarn
  }

  if (config.format === 'iife' || config.format === 'umd') {
    c.output.name = c.output.name || 'vue3-json-editor'
    c.output.extend = true
  }

  c.plugins = [...plugins]

  if (config.mode === 'production') {
    c.plugins.push(terser())
  }

  return c
}
Example #16
Source File: rollup.config.js    From fvtt-loot-sheet-npc-5e with MIT License 6 votes vote down vote up
config = {
    input: "src/lootsheetnpc5e.js",
    external: ["../../../../../systems/dnd5e/module/actor/sheets/npc.js"],
    output: {
        dir: "dist/",
        format: "es",
        sourcemap: true,
        assetFileNames: "[name].[ext]",
    },
    plugins: [
        replace({
            // If you would like DEV messages, specify 'development'
            // Otherwise use 'production'
            'process.env.NODE_ENV': JSON.stringify('production')
        }),
        nodeResolve({
            tippy: true,
        }),
        sourcemaps(),
        copy({
            watch: staticFiles,
            targets: staticFiles.map((file) => ({
                src: `${file}`,
                dest: "dist",
            })),
        }),
        terser({ ecma: 2020, keep_fnames: true }),
    ],
}
Example #17
Source File: createRollupConfig.js    From merkur with MIT License 6 votes vote down vote up
function createRollupES5Config() {
  let config = createRollupConfig();

  config.output = [
    {
      dir: './lib',
      entryFileNames: '[name].es5.js',
      format: 'cjs',
      exports: 'named',
      plugins: [getBabelOutputPlugin(babelES5BaseConfig), terser()],
    },
  ];

  return config;
}
Example #18
Source File: rollup.config.js    From hill-chart with MIT License 6 votes vote down vote up
commonOptions = {
  plugins: [
    cjs({
      include: 'node_modules/**',
    }),
    resolve(),
    babel({
      exclude: 'node_modules/**',
    }),

    production && terser(),
    postcss({
      extract: path.resolve('dist/styles.css'),
      plugins: [autoprefixer(), cssnano()],
    }),
    bundleSize(),
    visualizer({
      gzipSize: true,
    }),
  ],
}
Example #19
Source File: rollup.config.js    From pack11ty with MIT License 6 votes vote down vote up
plugins_critical = [
  commonjs(),
  resolve(),
  replace({
    'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
  }),
  babel({
    exclude: 'node_modules/**',
  }),
  process.env.NODE_ENV === 'production' && terser(),
  entrypointHashmanifest({
    manifestName: path.join(HASH, 'hashes_critical.json'),
  }),
]
Example #20
Source File: rollup.cjs.js    From webrix with Apache License 2.0 6 votes vote down vote up
production = {
    ...base,
    output: {
        dir: 'build',
        format: 'cjs',
        chunkFileNames: '[name].js',
        entryFileNames: '[name].js',
        preserveModules: true,
        preserveModulesRoot: 'src',
        sourcemap: false,
        exports: 'named',
        plugins: [terser()],
    },
    plugins: [
        ...base.plugins(),
        postcss({minimize: true}),
    ],
}
Example #21
Source File: rollup.config.js    From tom-select with Apache License 2.0 6 votes vote down vote up
terser_config = terser({
  mangle: true,
  //toplevel: true, // removes tomSelect footer
  format: {
    semicolons: false,
    comments: function (node, comment) {
      var text = comment.value;
      var type = comment.type;
      if (type == "comment2") {
        // multiline comment
        return /\* Tom Select/i.test(text);
      }
    },
  },
})
Example #22
Source File: rollup.config.js    From easy-toggler with MIT License 6 votes vote down vote up
configs = bundles.map(({ input: inputPath, output }) => ({
    input: inputPath,
    output,
    plugins: [
        nodeResolve(),
        babel({
            babelHelpers: 'bundled',
            plugins: ['annotate-pure-calls'],
        }),
        replace({
            __DEV__: false,
            preventAssignment: true,
        }),
        output.file.includes('.min.') && terser(),
    ],
}))
Example #23
Source File: rollup.config.js    From on-screen-keyboard-detector with MIT License 6 votes vote down vote up
plugins = [
		terser({
			include: [/^.+\.min\.m?js$/],
			output: {
				comments: function (node, comment) {
					var text = comment.value;
					var type = comment.type;
					if (type === 'comment2') {
						// multiline comment
						return /@license/i.test(text);
					}
				}
			}
		}),
		
		resolve()
	]
Example #24
Source File: rollup.config.js    From react-multi-date-picker with MIT License 6 votes vote down vote up
function build(dirName) {
  return fs.readdirSync("./src/" + dirName).map((path) => {
    let name = path
      .replace(/^./, (w) => w.toUpperCase())
      .replace(/_./g, (w) => w.replace("_", "").toUpperCase());

    return {
      input: `src/${dirName}/${path}/${path}.js`,
      output: [
        {
          file: `${dirName === "elements" ? "components" : dirName}/${path}.js`,
          format: "cjs",
          plugins: [terser()],
          exports: "named",
        },
        {
          file: `build/${path}.browser.js`,
          format: "umd",
          plugins: [terser()],
          name,
          exports: "default",
          globals,
        },
      ],
      ...getProps(),
    };
  });
}
Example #25
Source File: rollup.config.js    From yi-note with GNU General Public License v3.0 6 votes vote down vote up
module.exports = {
  input: 'src/index.js',
  output: [
    {
      file: 'dist/index.es.js',
      format: 'es',
      sourcemap: true
    },
    {
      file: 'dist/index.js',
      format: 'iife',
      name: 'ExtOauth2',
      sourcemap: true
    }
  ],
  plugins: [
    resolve(),
    babel({ exclude: 'node_modules/**' }),
    terser({
      include: [/^.+\.min\.js$/]
    })
  ]
};
Example #26
Source File: rollup.config.js    From tabler-icons with MIT License 6 votes vote down vote up
minUmdEsmPlugins = [
  babel({
    exclude: "node_modules/**",
  }),
  external(),
  resolve(),
  commonjs(),
  terser(),
  filesize(),
]
Example #27
Source File: package.js    From jsvectormap with MIT License 6 votes vote down vote up
module.exports = [
  {
    input: INPUT_FILE,
    output: {
      name: LIBRARY_NAME,
      file: 'dist/js/jsvectormap.js',
      format: 'umd',
    },
    plugins: [
      resolve(),
      babel({ babelHelpers: 'bundled' }),
      scss(scssOptions('jsvectormap'))
    ]
  },
  {
    input: INPUT_FILE,
    output: {
      name: LIBRARY_NAME,
      file: 'dist/js/jsvectormap.min.js',
      format: 'umd',
      plugins: [ terser() ]
    },
    plugins: [
      resolve(),
      babel({ babelHelpers: 'bundled' }),
      scss(scssOptions('jsvectormap.min', 'compressed'))
    ]
  }
]
Example #28
Source File: rollup.config.js    From wp2vite with MIT License 6 votes vote down vote up
config = {
  treeshake: {
    moduleSideEffects: 'no-external',
    propertyReadSideEffects: false,
    tryCatchDeoptimization: false,
  },
  input: {
    index: path.resolve(__dirname, 'src/main/start.js'),
    cli: path.resolve(__dirname, 'src/main/cli.js'),
  },
  external: [
    ...Object.keys(require('./package.json').dependencies),
  ],
  output: {
    dir: path.resolve(__dirname, 'dist/'),
    entryFileNames: `[name].js`,
    chunkFileNames: 'chunks/dep-[hash].js',
    exports: 'named',
    format: 'cjs',
    externalLiveBindings: false,
    freeze: false,
  },
  plugins: [
    nodeResolve({
      preferBuiltins: true,
    }),
    babel({
      babelHelpers: 'bundled',
      exclude: "node_modules/**",
    }),
    commonjs({
      extensions: ['.js'],
      ignoreDynamicRequires: true,
    }),
    json(),
    terser(),
  ],
}
Example #29
Source File: rollup.config.js    From flashsuite with GNU Affero General Public License v3.0 5 votes vote down vote up
toRollupConfig = component => {
  return {
    input: `svelte/${component}.js`,
    output: {
      sourcemap: true,
      format: 'iife',
      name: 'app',
      file: `docs/build/${component}.js`
    },
    plugins: [
      svelte({
        // customElement: true,
        // enable run-time checks when not in production
        dev: !production,
        // we'll extract any component CSS out into
        // a separate file - better for performance
        css: css => {
          css.write(`${component}.css`);
        },
      }),

      // If you have external dependencies installed from
      // npm, you'll most likely need these plugins. In
      // some cases you'll need additional configuration -
      // consult the documentation for details:
      // https://github.com/rollup/plugins/tree/master/packages/commonjs
      resolve({
        browser: true,
        dedupe: ['svelte']
      }),
      commonjs(),

      // In dev mode, call `npm run start` once
      // the bundle has been generated
      !production && serve(),

      // Watch the `public` directory and refresh the
      // browser on changes when not in production
      !production && livereload('docs'),

      // If we're building for production (npm run build
      // instead of npm run dev), minify
      production && terser()
    ],
    watch: {
      clearScreen: false
    },
    onwarn: function (warning) {
      // Skip certain warnings

      // should intercept ... but doesn't in some rollup versions
      if (warning.code === 'THIS_IS_UNDEFINED') { return; }

      // console.warn everything else
      console.warn(warning.message);
    }

  }
}