Skip to content

Commit

Permalink
fix(build): different builds (esm, cjs, umd, amd)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanGerbeth authored and MrTelanie committed Oct 25, 2019
1 parent 907a8cc commit 36b2a07
Show file tree
Hide file tree
Showing 4 changed files with 356 additions and 196 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jspm_packages
# Lib
lib
docs
build

# npm package lock
package-lock.json
Expand Down
89 changes: 57 additions & 32 deletions .rolluprc
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,72 @@ import resolve from 'rollup-plugin-node-resolve';
import minify from 'rollup-plugin-babel-minify';

const plugins = [
resolve(),
babel({
babelrc: false,
exclude: 'node_modules/**',
presets: [['@babel/preset-env', { modules: false }]]
}),
resolve(),
minify({
comments: false,
banner: '/* vector class - MIT License */',
bannerNewLine: true
})
];

export default [{
input: 'src/index.js',
output: {
name: 'basics.vector',
file: 'bundle.min.js',
format: 'umd',
exports: 'named',
extend: true
},
plugins
}, {
input: 'src/operator.js',
output: {
name: 'basics.vector.operator',
file: 'operator.min.js',
format: 'umd',
exports: 'named',
extend: true
},
plugins
}, {
input: 'src/adapter/playcanvas.js',
output: {
name: 'basics.vector.adapter.playcanvas',
file: 'adapter/playcanvas.min.js',
format: 'umd',
exports: 'named',
extend: true
},
plugins
}];
export default [
{
input: {
'default': 'src/index.js',
'operator': 'src/operator.js',
'adapter/playcanvas': 'src/adapter/playcanvas.js'
},
output: [{
dir: './build/esm',
exports: 'named',
format: 'esm'
}, {
dir: './build/cjs',
exports: 'named',
format: 'cjs'
}, {
dir: './build/amd',
exports: 'named',
format: 'amd'
}],
plugins
}, ...[
{
input: 'src/index.js',
output: {
file: 'bundle.min.js',
name: 'basics.vector'
}
}, {
input: 'src/operator.js',
output: {
file: 'operator.min.js',
name: 'basics.vector.operator'
}
}, {
input: 'src/adapter/playcanvas.js',
output: {
file: 'adapter/playcanvas.min.js',
name: 'basics.vector.adapter.playcanvas'
}
}
].map((item) => {
const format = 'umd';
return {
input: item.input,
output: {
file: `./build/${format}/${item.output.file}`,
name: item.output.name,
format: format,
exports: 'named',
extend: true
},
plugins
}
})
];
Loading

0 comments on commit 36b2a07

Please sign in to comment.