A better split into two versions
Additionally add some typing to the Rollup config filespull/14/head
parent
8f1d52e281
commit
522f0960d4
|
@ -14,13 +14,14 @@ const outputDir = isDev ? './dev/' : './dist/';
|
|||
|
||||
const bannerText = `${pkg.name} v${pkg.version} by Nikita Karamov\n${pkg.homepage}`;
|
||||
|
||||
/*
|
||||
* PLUGINS
|
||||
/**
|
||||
* Plugins to build the project
|
||||
*
|
||||
* @type {Plugin[]}
|
||||
*/
|
||||
|
||||
const plugins = [];
|
||||
|
||||
plugins.push(typescript());
|
||||
const plugins = [
|
||||
typescript(),
|
||||
];
|
||||
|
||||
if (!isDev) {
|
||||
plugins.push(strip({
|
||||
|
@ -51,58 +52,57 @@ plugins.push(postcss({
|
|||
],
|
||||
}));
|
||||
|
||||
/*
|
||||
* OUTPUTS
|
||||
/**
|
||||
* @typedef {import('rollup').OutputOptions} OutputOptions
|
||||
*/
|
||||
|
||||
const output = [];
|
||||
/**
|
||||
*
|
||||
* @param {string} baseDir base directory for the output files
|
||||
* @return {OutputOptions[]} array of outputs
|
||||
*/
|
||||
const getOutputs = (baseDir) => {
|
||||
const result = [];
|
||||
|
||||
if (isDev) {
|
||||
output.push({
|
||||
result.push({
|
||||
name: pkg.name,
|
||||
format: 'iife',
|
||||
file: `${outputDir}${pkg.name}.js`,
|
||||
file: `${baseDir}${pkg.name}.js`,
|
||||
});
|
||||
} else {
|
||||
output.push({
|
||||
result.push({
|
||||
name: pkg.name,
|
||||
format: 'cjs',
|
||||
file: `${outputDir}${pkg.name}.cjs`,
|
||||
file: `${baseDir}${pkg.name}.cjs`,
|
||||
});
|
||||
output.push({
|
||||
result.push({
|
||||
name: pkg.name,
|
||||
format: 'esm',
|
||||
file: `${outputDir}${pkg.name}.mjs`,
|
||||
file: `${baseDir}${pkg.name}.mjs`,
|
||||
});
|
||||
output.push({
|
||||
result.push({
|
||||
name: pkg.name,
|
||||
format: 'iife',
|
||||
file: `${outputDir}${pkg.name}.noinit.min.js`,
|
||||
file: `${baseDir}${pkg.name}.min.js`,
|
||||
plugins: [terser({ output: { comments: false } })],
|
||||
});
|
||||
}
|
||||
|
||||
const config = [{
|
||||
input: isDev ? './src/autoinit.ts' : './src/shareon.ts',
|
||||
output,
|
||||
plugins,
|
||||
}];
|
||||
return result;
|
||||
};
|
||||
|
||||
if (!isDev) {
|
||||
config.push({
|
||||
const config = [
|
||||
{
|
||||
input: './src/autoinit.ts',
|
||||
output: {
|
||||
name: pkg.name,
|
||||
format: 'iife',
|
||||
file: `${outputDir}${pkg.name}.min.js`,
|
||||
plugins: [terser({ output: { comments: false } })],
|
||||
},
|
||||
output: getOutputs(`${outputDir}`),
|
||||
plugins,
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* EXPORT
|
||||
*/
|
||||
},
|
||||
{
|
||||
input: './src/shareon.ts',
|
||||
output: getOutputs(`${outputDir}noinit/`),
|
||||
plugins: plugins.slice(0, -1),
|
||||
},
|
||||
];
|
||||
|
||||
export default config;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import './style.scss';
|
||||
|
||||
import initializeShareon from './shareon';
|
||||
|
||||
window.onload = () => {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import './style.scss';
|
||||
|
||||
interface PublishPreset {
|
||||
url: string,
|
||||
title: string,
|
||||
|
|
Loading…
Reference in New Issue