代码拉取完成,页面将自动刷新
import { mkdirSync, writeFileSync } from 'fs'
import { join } from 'path'
import replace from 'rollup-plugin-replace'
import { uglify } from 'rollup-plugin-uglify'
import commonJs from 'rollup-plugin-commonjs'
import typescript from 'rollup-plugin-typescript'
import resolve from 'rollup-plugin-node-resolve'
import { minify } from 'uglify-es'
// experimental minifier for ES modules
// https://github.com/TrySound/rollup-plugin-uglify#warning
const pkg = require('./package.json')
const productionPlugins = [
typescript({
typescript: require('typescript'),
}),
replace({
'process.env.NODE_ENV': "'production'",
}),
resolve(),
uglify(
{
compress: {
pure_getters: true,
unsafe: true,
},
output: {
comments: false,
semicolons: false,
},
mangle: {
reserved: ['payload', 'type', 'meta'],
},
},
minify
),
]
// minified production builds
const umdProduction = {
input: 'src/index.ts',
output: [
{
name: 'Rematch',
file: pkg.browser,
format: 'umd',
exports: 'named',
sourcemap: true,
}, // Universal Modules
],
plugins: productionPlugins
}
const cjsProduction = {
input: 'src/index.ts',
output: [
{
file: `${pkg.main}/rematch.min.js`,
format: 'cjs',
exports: 'named',
sourcemap: true,
}, // CommonJS Modules
],
plugins: productionPlugins.concat(commonJs())
}
// full source development builds
const development = {
input: 'src/index.ts',
output: [
{ file: `${pkg.main}/rematch.js`, format: 'cjs', exports: 'named' }, // CommonJS Modules
{ file: pkg.module, format: 'es', exports: 'named', sourcemap: true }, // ES Modules
],
plugins: [
typescript({
typescript: require('typescript'),
}),
replace({
'process.env.NODE_ENV': '"development"',
}),
resolve(),
],
}
// point user to needed build
const root = `"use strict";module.exports="production"===process.env.NODE_ENV?require("./rematch.min.js"):require("./rematch.js");`
const rootFile = folder => {
mkdirSync(join('dist', folder))
writeFileSync(join('dist', folder, 'index.js'), root)
}
export default (() => {
// generate root mapping files
mkdirSync('dist')
rootFile('cjs')
return [development, umdProduction, cjsProduction]
})()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。