Skip to content

Commit

Permalink
build(@vtmn/svelte): fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlahey committed Aug 17, 2022
1 parent 5f97e1c commit d2749de
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
15 changes: 9 additions & 6 deletions packages/sources/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
"test": "jest src",
"test:watch": "npm run test -- --watch"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^13.1.2",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/svelte": "^3.0.3",
"dependencies": {
"@vtmn/css-accordion": "^0.5.0",
"@vtmn/css-alert": "^0.8.3",
"@vtmn/css-badge": "^0.13.0",
Expand Down Expand Up @@ -67,7 +64,12 @@
"@vtmn/css-toast": "^0.7.2",
"@vtmn/css-toggle": "^0.8.2",
"@vtmn/css-tooltip": "^0.8.2",
"@vtmn/icons": "^0.14.0",
"@vtmn/icons": "^0.14.0"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^13.1.2",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/svelte": "^3.0.3",
"babel-jest": "^28.1.0",
"chokidar-cli": "^3.0.0",
"eslint": "8.18.0",
Expand All @@ -82,7 +84,8 @@
"rollup-plugin-svelte": "^7.1.0",
"svelte": "3.49.0",
"svelte-jester": "^2.3.2",
"svelte-preprocess": "4.10.7"
"svelte-preprocess": "4.10.7",
"rollup-plugin-terser": "^7.0.2"
},
"jest": {
"testEnvironment": "jsdom",
Expand Down
29 changes: 26 additions & 3 deletions packages/sources/svelte/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import postcssImport from 'postcss-import';
import postcssUrl from 'postcss-url';
import fs from 'fs';
import path from 'path';
import pkg from './package.json';
import { terser } from 'rollup-plugin-terser';

const preprocessOptions = require('./svelte.config').preprocessOptions;

Expand Down Expand Up @@ -40,17 +42,38 @@ const postcssProcess = (component, variant = '') =>
],
});

const globals = {
'svelte/internal': 'svelte/internal',
svelte: 'svelte',
};

const svelteOptions = (component, variant) => ({
external: /^svelte.*$/,
output: [
{ file: `dist/index.mjs`, format: 'es' },
{ file: `dist/index.js`, format: 'umd', name: 'index' },
{
file: pkg.module,
format: 'es',
sourcemap: true,
globals,
},
{
file: pkg.main,
format: 'umd',
name: 'index',
sourcemap: true,
globals,
},
],
plugins: [
svelte({
preprocess: sveltePreprocess(preprocessOptions),
}),
postcssProcess(component, variant),
resolve(),
resolve({
// Exclude all svelte related stuff
resolveOnly: [/^(?!svelte.*$)/],
}),
terser(),
],
});

Expand Down

0 comments on commit d2749de

Please sign in to comment.