diff --git a/package.json b/package.json index f082091..ffdcfb4 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "@babel/core": "^7.6.4", "@babel/plugin-proposal-class-properties": "^7.5.5", "@babel/plugin-proposal-decorators": "^7.4.0", + "@rollup/plugin-json": "^4.0.0", "@typescript-eslint/eslint-plugin": "^2.6.0", "@typescript-eslint/parser": "^2.6.0", "eslint": "^6.6.0", @@ -34,6 +35,7 @@ "prettier": "^1.18.2", "rollup": "^1.26.0", "rollup-plugin-babel": "^4.3.3", + "rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-serve": "^1.0.1", "rollup-plugin-terser": "^5.1.2", @@ -42,7 +44,7 @@ "typescript": "^3.6.4" }, "scripts": { - "start": "rollup -c rollup.config.dev.js --watch", + "start": "rollup -c --watch", "build": "npm run lint && npm run rollup", "lint": "eslint src/*.ts", "rollup": "rollup -c" diff --git a/rollup.config.dev.js b/rollup.config.dev.js deleted file mode 100644 index 7e2433a..0000000 --- a/rollup.config.dev.js +++ /dev/null @@ -1,24 +0,0 @@ -import resolve from 'rollup-plugin-node-resolve'; -import typescript from 'rollup-plugin-typescript2'; -import serve from 'rollup-plugin-serve'; - -export default { - input: ['src/boilerplate-card.ts'], - output: { - dir: './dist', - format: 'es', - }, - plugins: [ - resolve(), - typescript(), - serve({ - contentBase: './dist', - host: '0.0.0.0', - port: 5000, - allowCrossOrigin: true, - headers: { - 'Access-Control-Allow-Origin': '*', - }, - }), - ], -}; diff --git a/rollup.config.js b/rollup.config.js index 41a126e..5586c3c 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,20 +1,42 @@ -import resolve from "rollup-plugin-node-resolve"; -import typescript from "rollup-plugin-typescript2"; -import babel from "rollup-plugin-babel"; -import { terser } from "rollup-plugin-terser"; +import typescript from 'rollup-plugin-typescript2'; +import commonjs from 'rollup-plugin-commonjs'; +import nodeResolve from 'rollup-plugin-node-resolve'; +import babel from 'rollup-plugin-babel'; +import { terser } from 'rollup-plugin-terser'; +import serve from 'rollup-plugin-serve'; +import json from '@rollup/plugin-json'; -export default { - input: ["src/boilerplate-card.ts"], - output: { - dir: "./dist", - format: "es" +const dev = process.env.ROLLUP_WATCH; + +const serveopts = { + contentBase: ['./dist'], + host: '0.0.0.0', + port: 5000, + allowCrossOrigin: true, + headers: { + 'Access-Control-Allow-Origin': '*', }, - plugins: [ - resolve(), - typescript(), - babel({ - exclude: "node_modules/**" - }), - terser(), - ] }; + +const plugins = [ + nodeResolve({}), + commonjs(), + typescript(), + json(), + babel({ + exclude: 'node_modules/**', + }), + dev && serve(serveopts), + !dev && terser(), +]; + +export default [ + { + input: 'src/boilerplate-card.ts', + output: { + dir: 'dist', + format: 'es', + }, + plugins: [...plugins], + }, +];