Skip to content

Commit

Permalink
new assembly approach
Browse files Browse the repository at this point in the history
  • Loading branch information
uvarov-frontend committed Sep 14, 2023
1 parent efac346 commit 18bf724
Show file tree
Hide file tree
Showing 10 changed files with 1,698 additions and 28 deletions.
13 changes: 5 additions & 8 deletions package.config.ts → config/assets.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { resolve } from 'path';
import { defineConfig } from 'vite';
import banner from 'vite-plugin-banner';
import eslint from 'vite-plugin-eslint';

export default defineConfig({
publicDir: './package/public',
Expand All @@ -11,12 +10,11 @@ export default defineConfig({
assetsDir: '',
outDir: './package/build',
cssCodeSplit: true,
minify: 'terser',
minify: true,
emptyOutDir: false,
rollupOptions: {
output: {
inlineDynamicImports: false,
format: 'cjs',
entryFileNames: '[name].min.js',
assetFileNames: (assetInfo) => {
if (assetInfo.name && ['light.css', 'dark.css'].includes(assetInfo.name)) {
return 'themes/[name].min.[ext]';
Expand All @@ -25,9 +23,9 @@ export default defineConfig({
},
},
input: {
light: resolve(__dirname, './package/src/styles/themes/light.css'),
dark: resolve(__dirname, './package/src/styles/themes/dark.css'),
'vanilla-calendar': resolve(__dirname, './package/src/vanilla-calendar.ts'),
light: resolve(__dirname, '../package/src/styles/themes/light.css'),
dark: resolve(__dirname, '../package/src/styles/themes/dark.css'),
'vanilla-calendar': resolve(__dirname, '../package/src/styles/vanilla-calendar.css'),
},
},
},
Expand All @@ -36,6 +34,5 @@ export default defineConfig({
outDir: './package/build',
content: 'name: @uvarov.frontend/vanilla-calendar | url: https://github.com/uvarov-frontend/vanilla-calendar',
}),
eslint(),
],
});
26 changes: 26 additions & 0 deletions config/js.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-disable import/no-extraneous-dependencies */
import { resolve } from 'path';
import { defineConfig } from 'vite';
import banner from 'vite-plugin-banner';
import eslint from 'vite-plugin-eslint';

export default defineConfig({
build: {
target: 'ES6',
assetsDir: '',
outDir: './package/build',
minify: 'terser',
lib: {
name: 'VanillaCalendar',
fileName(format, entryName) { return `${entryName}.min${format === 'es' ? '.mjs' : '.js'}`; },
entry: resolve(__dirname, '../package/src/scripts/vanilla-calendar.ts'),
},
},
plugins: [
banner({
outDir: './package/build',
content: 'name: @uvarov.frontend/vanilla-calendar | url: https://github.com/uvarov-frontend/vanilla-calendar',
}),
eslint(),
],
});
7 changes: 4 additions & 3 deletions demo/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import '@/package/src/styles/vanilla-calendar.css';
import '@/package/src/styles/themes/light.css';
import '@/package/src/styles/themes/dark.css';
import VanillaCalendar from '@/package/src/scripts/main';
import { Options } from '@/package/src';
// import VanillaCalendar from '@/package/build/vanilla-calendar.min';
import VanillaCalendar from '@/package/src/scripts/vanilla-calendar';
import IVanillaCalendar, { Options } from '@/package/src';

const config: Options = {
settings: {
Expand All @@ -16,6 +17,6 @@ const config: Options = {

document.addEventListener('DOMContentLoaded', () => {
// @ts-ignore: VanillaCalendar config
const calendar = new VanillaCalendar('#calendar', config);
const calendar: IVanillaCalendar<string, Options> = new VanillaCalendar('#calendar', config);
calendar.init();
});
7 changes: 4 additions & 3 deletions demo/pages/multiple/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import '@/package/src/styles/vanilla-calendar.css';
import '@/package/src/styles/themes/light.css';
import '@/package/src/styles/themes/dark.css';
import VanillaCalendar from '@/package/src/scripts/main';
import { Options } from '@/package/src';
// import VanillaCalendar from '@/package/build/vanilla-calendar.min';
import VanillaCalendar from '@/package/src/scripts/vanilla-calendar';
import IVanillaCalendar, { Options } from '@/package/src';

const config: Options = {
type: 'multiple',
Expand All @@ -20,6 +21,6 @@ const config: Options = {

document.addEventListener('DOMContentLoaded', () => {
// @ts-ignore: VanillaCalendar config
const calendar = new VanillaCalendar('#calendar', config);
const calendar: IVanillaCalendar<string, Options> = new VanillaCalendar('#calendar', config);
calendar.init();
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
]
},
"scripts": {
"package": "tsc && vite build --config package.config.ts",
"package": "tsc && vite build --config config/js.config.ts && vite build --config config/assets.config.ts",
"build": "tsc && vite build",
"start": "tsc && vite",
"lint": "eslint --ext .js,.ts package/src cypress examples",
Expand Down
2 changes: 1 addition & 1 deletion package/build/vanilla-calendar.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 18bf724

Please sign in to comment.