Split package into two files

pull/14/head
Nikita Karamov 2020-07-23 11:13:21 +02:00
parent b3a4cd1593
commit 8f1d52e281
No known key found for this signature in database
GPG Key ID: E40DFE6E993540FF
3 changed files with 28 additions and 9 deletions

View File

@ -10,7 +10,6 @@ const isDev = process.env.ROLLUP_WATCH || process.env.NODE_ENV === 'development'
const pkg = require('./package.json');
const inputFile = './src/index.ts';
const outputDir = isDev ? './dev/' : './dist/';
const bannerText = `${pkg.name} v${pkg.version} by Nikita Karamov\n${pkg.homepage}`;
@ -76,10 +75,29 @@ if (isDev) {
file: `${outputDir}${pkg.name}.mjs`,
});
output.push({
name: pkg.name,
format: 'iife',
file: `${outputDir}${pkg.name}.noinit.min.js`,
plugins: [terser({ output: { comments: false } })],
});
}
const config = [{
input: isDev ? './src/autoinit.ts' : './src/shareon.ts',
output,
plugins,
}];
if (!isDev) {
config.push({
input: './src/autoinit.ts',
output: {
name: pkg.name,
format: 'iife',
file: `${outputDir}${pkg.name}.min.js`,
plugins: [terser({ output: { comments: false } })],
},
plugins,
});
}
@ -87,8 +105,4 @@ if (isDev) {
* EXPORT
*/
export default {
input: inputFile,
output,
plugins,
};
export default config;

7
src/autoinit.ts Normal file
View File

@ -0,0 +1,7 @@
import initializeShareon from './shareon';
window.onload = () => {
initializeShareon();
};
export default initializeShareon;

View File

@ -71,6 +71,4 @@ const initializeShareon = () : void => {
}
};
window.onload = () => { initializeShareon(); };
export default initializeShareon;