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}`;
|
const bannerText = `${pkg.name} v${pkg.version} by Nikita Karamov\n${pkg.homepage}`;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* PLUGINS
|
* Plugins to build the project
|
||||||
|
*
|
||||||
|
* @type {Plugin[]}
|
||||||
*/
|
*/
|
||||||
|
const plugins = [
|
||||||
const plugins = [];
|
typescript(),
|
||||||
|
];
|
||||||
plugins.push(typescript());
|
|
||||||
|
|
||||||
if (!isDev) {
|
if (!isDev) {
|
||||||
plugins.push(strip({
|
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) {
|
if (isDev) {
|
||||||
output.push({
|
result.push({
|
||||||
name: pkg.name,
|
name: pkg.name,
|
||||||
format: 'iife',
|
format: 'iife',
|
||||||
file: `${outputDir}${pkg.name}.js`,
|
file: `${baseDir}${pkg.name}.js`,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
output.push({
|
result.push({
|
||||||
name: pkg.name,
|
name: pkg.name,
|
||||||
format: 'cjs',
|
format: 'cjs',
|
||||||
file: `${outputDir}${pkg.name}.cjs`,
|
file: `${baseDir}${pkg.name}.cjs`,
|
||||||
});
|
});
|
||||||
output.push({
|
result.push({
|
||||||
name: pkg.name,
|
name: pkg.name,
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
file: `${outputDir}${pkg.name}.mjs`,
|
file: `${baseDir}${pkg.name}.mjs`,
|
||||||
});
|
});
|
||||||
output.push({
|
result.push({
|
||||||
name: pkg.name,
|
name: pkg.name,
|
||||||
format: 'iife',
|
format: 'iife',
|
||||||
file: `${outputDir}${pkg.name}.noinit.min.js`,
|
file: `${baseDir}${pkg.name}.min.js`,
|
||||||
plugins: [terser({ output: { comments: false } })],
|
plugins: [terser({ output: { comments: false } })],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = [{
|
return result;
|
||||||
input: isDev ? './src/autoinit.ts' : './src/shareon.ts',
|
};
|
||||||
output,
|
|
||||||
plugins,
|
|
||||||
}];
|
|
||||||
|
|
||||||
if (!isDev) {
|
const config = [
|
||||||
config.push({
|
{
|
||||||
input: './src/autoinit.ts',
|
input: './src/autoinit.ts',
|
||||||
output: {
|
output: getOutputs(`${outputDir}`),
|
||||||
name: pkg.name,
|
|
||||||
format: 'iife',
|
|
||||||
file: `${outputDir}${pkg.name}.min.js`,
|
|
||||||
plugins: [terser({ output: { comments: false } })],
|
|
||||||
},
|
|
||||||
plugins,
|
plugins,
|
||||||
});
|
},
|
||||||
}
|
{
|
||||||
|
input: './src/shareon.ts',
|
||||||
/*
|
output: getOutputs(`${outputDir}noinit/`),
|
||||||
* EXPORT
|
plugins: plugins.slice(0, -1),
|
||||||
*/
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
import initializeShareon from './shareon';
|
import initializeShareon from './shareon';
|
||||||
|
|
||||||
window.onload = () => {
|
window.onload = () => {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import './style.scss';
|
|
||||||
|
|
||||||
interface PublishPreset {
|
interface PublishPreset {
|
||||||
url: string,
|
url: string,
|
||||||
title: string,
|
title: string,
|
||||||
|
|
Loading…
Reference in New Issue