|
| 1 | +import {importStyles} from "@appnest/web-config"; |
| 2 | +import ts from '@wessberg/rollup-plugin-ts'; |
| 3 | +import autoprefixer from 'autoprefixer'; |
| 4 | +import {generate} from 'escodegen'; |
| 5 | +import {parse} from 'esprima'; |
| 6 | +import {minify} from 'html-minifier'; |
| 7 | +import {createServer} from 'livereload'; |
| 8 | +import cssnano from 'cssnano'; |
| 9 | +import path from 'path'; |
| 10 | +import precss from 'precss'; |
| 11 | +import cleaner from 'rollup-plugin-cleaner'; |
| 12 | +import commonjs from 'rollup-plugin-commonjs'; |
| 13 | +import resolve from 'rollup-plugin-node-resolve'; |
| 14 | +import progress from 'rollup-plugin-progress'; |
| 15 | +import pkg from "./package.json"; |
| 16 | + |
| 17 | +const folders = { |
| 18 | + src: path.resolve(__dirname, "src/lib"), |
| 19 | + dist: path.resolve(__dirname, "dist"), |
| 20 | +}; |
| 21 | + |
| 22 | +const files = { |
| 23 | + src_index: path.join(folders.src, "index.ts"), |
| 24 | + dist_index: path.join(folders.dist, "index.js") |
| 25 | +}; |
| 26 | + |
| 27 | +const defaultConfig = { |
| 28 | + plugins: [ |
| 29 | + progress(), |
| 30 | + cleaner({ |
| 31 | + targets: [ |
| 32 | + folders.dist |
| 33 | + ] |
| 34 | + }), |
| 35 | + resolve(), |
| 36 | + importStyles({ |
| 37 | + plugins: [ |
| 38 | + precss(), |
| 39 | + autoprefixer(), |
| 40 | + cssnano({preset: ["default", { |
| 41 | + calc: false |
| 42 | + }]}) |
| 43 | + ] |
| 44 | + }), |
| 45 | + // Teaches Rollup how to transpile Typescript |
| 46 | + // https://github.com/wessberg/rollup-plugin-ts |
| 47 | + ts({ |
| 48 | + transpiler: "typescript", |
| 49 | + // If your tsconfig is already called 'tsconfig.json', this option can be left out |
| 50 | + tsconfig: "tsconfig.build.json", |
| 51 | + exclude: ["node_modules/**/*.*"], |
| 52 | + // If there is no .browserslistrc within your project, and if your package.json doesn't include a Browserslist property, this option can be left out |
| 53 | + browserslist: false |
| 54 | + }), |
| 55 | + |
| 56 | + // At the moment, the majority of packages on NPM are exposed as CommonJS modules |
| 57 | + commonjs({ |
| 58 | + include: "**/node_modules/**", |
| 59 | + }) |
| 60 | + ], |
| 61 | + external: [ |
| 62 | + ...Object.keys(pkg.dependencies), |
| 63 | + ...Object.keys(pkg.devDependencies), |
| 64 | + "@appnest/focus-trap/debounce", |
| 65 | + "lit-html/directives/if-defined", |
| 66 | + "tslib" |
| 67 | + ], |
| 68 | + treeshake: false, |
| 69 | + preserveModules: true |
| 70 | +}; |
| 71 | + |
| 72 | +const configs = [ |
| 73 | + { |
| 74 | + input: files.src_index, |
| 75 | + output: [ |
| 76 | + { |
| 77 | + format: "esm", |
| 78 | + dir: folders.dist |
| 79 | + } |
| 80 | + ], |
| 81 | + ...defaultConfig |
| 82 | + }, |
| 83 | +]; |
| 84 | + |
| 85 | +export default configs; |
| 86 | + |
0 commit comments