12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- const fs = require('fs-extra')
- const path = require('path')
- const babel = require('rollup-plugin-babel');
- const { uglify } = require('rollup-plugin-uglify');
- const PATH = `./.laser-lib-path`
- const buildPaths = [
- `build`,
- ...fs.existsSync(PATH) ? [fs.readFileSync(PATH).toString()] : []
- ]
- const builds = []
- for (const dir of buildPaths) {
- builds.push(
- ...[
- {
- input: 'src/Potree.js',
- treeshake: false,
- output: {
- file: `${dir}/potree/potree.js`,
- format: 'umd',
- name: 'Potree',
- sourcemap: true,
- }
- }, {
- input: 'src/workers/BinaryDecoderWorker.js',
- output: {
- file: `${dir}/potree/workers/BinaryDecoderWorker.js`,
- format: 'es',
- name: 'Potree',
- sourcemap: false
- }
- },{
- input: 'src/modules/loader/2.0/DecoderWorker.js',
- output: {
- file: `${dir}/potree/workers/2.0/DecoderWorker.js`,
- format: 'es',
- name: 'Potree',
- sourcemap: false
- }
- },{
- input: 'src/modules/loader/2.0/DecoderWorker_brotli.js',
- output: {
- file: `${dir}/potree/workers/2.0/DecoderWorker_brotli.js`,
- format: 'es',
- name: 'Potree',
- sourcemap: false
- }
- }
- ]
- )
- }
- if (process.env.npm_lifecycle_script.includes('production')) {
- builds.forEach(item => {
- item.output.sourcemap = false
- item.plugins = [
- [
- '@babel/plugin-transform-runtime',
- ],
- babel({
- presets: ['@babel/preset-env'],
- exclude: "node_modules/**"
- }),
- // 压缩代码
- uglify()
- ]
- })
- } else {
- builds.forEach(item => {
- item.plugins = [
- babel({
- presets: [
- [
- '@babel/preset-env',
- {
- targets: {
- esmodules: true, // 目标是 ES 模块
- },
- },
- ],
- ],
- exclude: 'node_modules/**', // 排除 node_modules 目录
- }),
- ]
- })
- }
- export default builds
|