Mercurial > code > home > repos > streamed-graph
diff rollup.config.js @ 48:b8e5850acca0
local demo; styles
author | drewp@bigasterisk.com |
---|---|
date | Thu, 09 Jan 2020 00:04:45 -0800 |
parents | 7d17a02b5ae0 |
children | 1264ba9ffb10 |
line wrap: on
line diff
--- a/rollup.config.js Mon Jan 06 23:52:30 2020 -0800 +++ b/rollup.config.js Thu Jan 09 00:04:45 2020 -0800 @@ -1,31 +1,65 @@ import builtins from "rollup-plugin-node-builtins"; import commonjs from "@rollup/plugin-commonjs"; +import postcss from "rollup-plugin-postcss"; import resolve from "@rollup/plugin-node-resolve"; import typescript from "rollup-plugin-typescript2"; -export default { +const workaround_jsonld_module_system_picker = "process = {version: '1.0.0'}"; +const workaround_some_browser_detector = "global = window"; +const workaround_jsonld_expand_issue = { + namedExports: { + jsonld: ["expand"] // fixes "expand is not exported by node_modules/jsonld/lib/index.js" + } +}; + +export default [ + { input: "src/index.ts", output: { - file: "build/bundle.js", - format: "cjs", // just for the namedExports hack - intro: "const global = window;", - + file: "build/bundle.js", + format: "esm", + intro: `const ${workaround_some_browser_detector}, ${workaround_jsonld_module_system_picker};` }, - // only for final build. demo page does need these modules, so I guess this file should observe some kind of build mode. - external: ['@polymer/polymer','lit-html','@polymer/decorators','n3','jsonld'], + external: [ + "@polymer/polymer", + "lit-html", + "@polymer/decorators", + "n3", + "jsonld" + ], plugins: [ - builtins(), - resolve({ - extensions: [".js", ".ts"], - browser: true, - only: ['streamed-graph'] - }), - typescript(), - commonjs({ - namedExports: { - 'jsonld': ['expand'], // fixes "expand is not exported by node_modules/jsonld/lib/index.js" - } - }), - + builtins(), + resolve({ + extensions: [".js", ".ts"], + browser: true, + only: ["streamed-graph"] + }), + typescript(), + postcss({ + inject: false + }), + commonjs(workaround_jsonld_expand_issue) ] -}; + }, + { + input: "src/demo.ts", + output: { + file: "build/demo.js", + format: "esm", + intro: `const ${workaround_some_browser_detector}, ${workaround_jsonld_module_system_picker};` + }, + external: [], + plugins: [ + builtins(), + resolve({ + extensions: [".js", ".ts"], + browser: true + }), + typescript(), + postcss({ + inject: false + }), + commonjs(workaround_jsonld_expand_issue) + ] + } +];