mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Switched to type: module.
This commit is contained in:
parent
615a6d444f
commit
4e37e10b6d
20 changed files with 25 additions and 50 deletions
80
rollup.components.config.js
Normal file
80
rollup.components.config.js
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
import path from 'path';
|
||||
import crypto from 'crypto';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import alias from '@rollup/plugin-alias';
|
||||
import json from '@rollup/plugin-json';
|
||||
import postcss from 'rollup-plugin-postcss';
|
||||
import copy from 'rollup-plugin-copy';
|
||||
import del from 'rollup-plugin-delete';
|
||||
import nodeExternals from 'rollup-plugin-node-externals';
|
||||
import esbuild from 'rollup-plugin-esbuild';
|
||||
import dts from 'rollup-plugin-dts';
|
||||
import svgr from '@svgr/rollup';
|
||||
|
||||
const md5 = str => crypto.createHash('md5').update(str).digest('hex');
|
||||
|
||||
const customResolver = resolve({
|
||||
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
||||
});
|
||||
|
||||
const aliasConfig = {
|
||||
entries: [
|
||||
{ find: /^@/, replacement: path.resolve('./src/') },
|
||||
{ find: /^public/, replacement: path.resolve('./public') },
|
||||
],
|
||||
customResolver,
|
||||
};
|
||||
|
||||
const jsBundle = {
|
||||
input: 'src/index.ts',
|
||||
output: [
|
||||
{
|
||||
file: 'dist/index.js',
|
||||
format: 'es',
|
||||
sourcemap: true,
|
||||
},
|
||||
],
|
||||
plugins: [
|
||||
del({ targets: 'dist/*', runOnce: true }),
|
||||
copy({ targets: [{ src: './package.components.json', dest: 'dist', rename: 'package.json' }] }),
|
||||
postcss({
|
||||
config: false,
|
||||
extract: 'styles.css',
|
||||
sourceMap: true,
|
||||
minimize: true,
|
||||
modules: {
|
||||
generateScopedName: function (name, filename, css) {
|
||||
const file = path.basename(filename, '.css').replace('.module', '');
|
||||
const hash = Buffer.from(md5(`${name}:${filename}:${css}`))
|
||||
.toString('base64')
|
||||
.substring(0, 5);
|
||||
|
||||
return `${file}-${name}--${hash}`;
|
||||
},
|
||||
},
|
||||
}),
|
||||
svgr({ icon: true }),
|
||||
nodeExternals(),
|
||||
json(),
|
||||
alias(aliasConfig),
|
||||
esbuild({
|
||||
target: 'es6',
|
||||
jsx: 'automatic',
|
||||
loaders: {
|
||||
'.js': 'jsx',
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
const dtsBundle = {
|
||||
input: 'src/index.ts',
|
||||
output: {
|
||||
file: 'dist/index.d.ts',
|
||||
format: 'es',
|
||||
},
|
||||
plugins: [alias(aliasConfig), nodeExternals(), json(), dts()],
|
||||
external: [/\.css/],
|
||||
};
|
||||
|
||||
export default [jsBundle, dtsBundle];
|
||||
Loading…
Add table
Add a link
Reference in a new issue