├── .eslintignore ├── .eslintrc.json ├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── babel.config.js ├── build ├── images │ ├── .DS_Store │ ├── death.png │ ├── judgement.png │ ├── justice.png │ ├── strength.png │ ├── temperance.png │ ├── the-chariot.png │ ├── the-devil.png │ ├── the-emperor.png │ ├── the-empress.png │ ├── the-fool.png │ ├── the-hanged-man.png │ ├── the-hermit.png │ ├── the-hierophant.png │ ├── the-high-priestess.png │ ├── the-lovers.png │ ├── the-magician.png │ ├── the-moon.png │ ├── the-star.png │ ├── the-sun.png │ ├── the-tower.png │ ├── the-world.png │ └── wheel-of-fortune.png └── index.html ├── netlify.toml ├── package-lock.json ├── package.json ├── screenshots ├── tarot-widget-example.png └── tarot-widget-for-website.png ├── scripts ├── getPackageJson.js └── testMock.js ├── src ├── TarotWidget.js ├── actions │ ├── cardStateStorage.js │ └── renderWidgetHtml.js ├── automount.js ├── cards-map.json ├── config.json ├── index.css └── index.js └── webpack.config.js /.eslintignore: -------------------------------------------------------------------------------- 1 | build/* -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "parserOptions": { 4 | "ecmaVersion": 6, 5 | "sourceType": "module", 6 | "ecmaFeatures": { 7 | "modules": true, 8 | "experimentalObjectRestSpread": true 9 | } 10 | }, 11 | "plugins": [], 12 | "extends": ["eslint:recommended"], 13 | "rules": { 14 | "comma-dangle": 0, 15 | "no-unused-vars": "warn", 16 | "no-unexpected-multiline": "warn", 17 | "prefer-const": "warn" 18 | }, 19 | "settings": {}, 20 | "env": { 21 | "browser": true, 22 | "node": true, 23 | "jasmine": true, 24 | "jest": true, 25 | "es6": true 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode 3 | .DS_Store 4 | ./**/.DS_Store 5 | 6 | build/* 7 | !build/index.html 8 | !build/images 9 | !build/images/* -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # testing 5 | /tests 6 | /coverage 7 | 8 | # docs 9 | /docs 10 | 11 | # misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | /.github 18 | /demo 19 | .esdoc.json 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | 25 | # Development folders and files 26 | public 27 | src 28 | scripts 29 | config 30 | .travis.yml 31 | CHANGELOG.md 32 | README.md 33 | webpack.config.js 34 | babel.config.js -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Alex Brik 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Tarot widget for Website

2 |

Super tiny (only 4kb minified) javascript library to add awesome Tarot widget to your website.

3 |

4 | Tarot widget for website 5 |

6 |

(This is a screenshot as an example)

7 | 8 | ## Features 9 | * Random selection of one of 22 Major Arcana (Raider Waite Tarot Deck). 10 | * A unique card for each viewer for 24 hours. 11 | * Short advice of the card and the opportunity to read a detailed interpretation at will. 12 | * The transparent background provides a nice appearance of the widget on the website with any design. 13 | * A super small size that will not affect the speed of your site. 14 | 15 | ## How To Install (Easy way) 16 | Just copy the code below and paste it where you want to see the widget. 17 | 18 | ``` 19 |
20 | 22 | ``` 23 | Thats all. 24 | 25 | ## Usage via npm 26 | 27 | ![npm](https://img.shields.io/npm/dm/mo-tarot-widget?style=flat-square) 28 | 29 | Install package: 30 | 31 | ``` 32 | npm install mo-tarot-widget 33 | ``` 34 | Import code and styles (if you want): 35 | ```javascript 36 | import TarotWidget from 'mo-tarot-widget' 37 | 38 | import 'mo-tarot-widget/src/index.css' 39 | 40 | new TarotWidget('some-element-id') 41 | ``` 42 | 43 | ## Contacts 44 | More information about Tarot Card Major Arcana meaning you can find [here](https://moonorganizer.com/en/tarot-card-major-arcana-meaning/) 45 | 46 | Fill free to contact me if you need help with customization or installation. 47 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | ["@babel/env"] 4 | ], 5 | plugins: [ 6 | ["@babel/plugin-proposal-class-properties"] 7 | ] 8 | }; -------------------------------------------------------------------------------- /build/images/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/.DS_Store -------------------------------------------------------------------------------- /build/images/death.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/death.png -------------------------------------------------------------------------------- /build/images/judgement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/judgement.png -------------------------------------------------------------------------------- /build/images/justice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/justice.png -------------------------------------------------------------------------------- /build/images/strength.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/strength.png -------------------------------------------------------------------------------- /build/images/temperance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/temperance.png -------------------------------------------------------------------------------- /build/images/the-chariot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-chariot.png -------------------------------------------------------------------------------- /build/images/the-devil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-devil.png -------------------------------------------------------------------------------- /build/images/the-emperor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-emperor.png -------------------------------------------------------------------------------- /build/images/the-empress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-empress.png -------------------------------------------------------------------------------- /build/images/the-fool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-fool.png -------------------------------------------------------------------------------- /build/images/the-hanged-man.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-hanged-man.png -------------------------------------------------------------------------------- /build/images/the-hermit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-hermit.png -------------------------------------------------------------------------------- /build/images/the-hierophant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-hierophant.png -------------------------------------------------------------------------------- /build/images/the-high-priestess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-high-priestess.png -------------------------------------------------------------------------------- /build/images/the-lovers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-lovers.png -------------------------------------------------------------------------------- /build/images/the-magician.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-magician.png -------------------------------------------------------------------------------- /build/images/the-moon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-moon.png -------------------------------------------------------------------------------- /build/images/the-star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-star.png -------------------------------------------------------------------------------- /build/images/the-sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-sun.png -------------------------------------------------------------------------------- /build/images/the-tower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-tower.png -------------------------------------------------------------------------------- /build/images/the-world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/the-world.png -------------------------------------------------------------------------------- /build/images/wheel-of-fortune.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/build/images/wheel-of-fortune.png -------------------------------------------------------------------------------- /build/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Tarot Widget Demo 7 | 8 | 9 | 16 | 17 | 20 |
21 |
22 |
23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | publish = "build" 3 | command = "npm run build" -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mo-tarot-widget", 3 | "version": "1.0.1", 4 | "description": "Tarot widget for website", 5 | "main": "build/index.js", 6 | "scripts": { 7 | "build": "webpack", 8 | "test": "jest", 9 | "prepare": "npm run build", 10 | "trypublish": "npm publish || true" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/g00dv1n/mo-tarot-widget" 15 | }, 16 | "author": "Alex Brik ", 17 | "license": "MIT", 18 | "bugs": { 19 | "url": "https://github.com/g00dv1n/mo-tarot-widget/issues" 20 | }, 21 | "homepage": "https://moonorganizer.com/en/tarot-card-major-arcana-meaning/", 22 | "keywords": [ 23 | "widget", 24 | "tarot" 25 | ], 26 | "devDependencies": { 27 | "@babel/cli": "^7.12.8", 28 | "@babel/core": "^7.12.9", 29 | "@babel/plugin-proposal-class-properties": "^7.12.1", 30 | "@babel/polyfill": "^7.12.1", 31 | "@babel/preset-env": "^7.12.7", 32 | "babel-eslint": "^10.1.0", 33 | "babel-loader": "^8.2.2", 34 | "babel-preset-minify": "^0.5.0", 35 | "css-loader": "^5.0.1", 36 | "eslint": "^7.14.0", 37 | "file-loader": "^6.2.0", 38 | "jest": "^26.6.3", 39 | "prettier": "^2.2.1", 40 | "prettier-webpack-plugin": "^1.2.0", 41 | "style-loader": "^2.0.0", 42 | "terser-webpack-plugin": "^5.0.3", 43 | "url-loader": "^4.1.1", 44 | "webpack": "^5.9.0", 45 | "webpack-cli": "^4.2.0" 46 | }, 47 | "dependencies": { 48 | "js-cookie": "^2.2.1" 49 | }, 50 | "jest": { 51 | "moduleNameMapper": { 52 | "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/scripts/testMock.js", 53 | "\\.(css|less)$": "/scripts/testMock.js" 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /screenshots/tarot-widget-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/screenshots/tarot-widget-example.png -------------------------------------------------------------------------------- /screenshots/tarot-widget-for-website.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g00dv1n/mo-tarot-widget/9214638ea9bed878f846b25aed96df2bd7002dab/screenshots/tarot-widget-for-website.png -------------------------------------------------------------------------------- /scripts/getPackageJson.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | 4 | /** 5 | * A module to get package informations from package.json 6 | * @module getPackageJson 7 | * @param {...string} keys from package.json if no arguments passed it returns package.json content as object 8 | * @returns {object} with given keys or content of package.json as object 9 | */ 10 | 11 | /** 12 | * Returns package info 13 | */ 14 | const getPackageJson = function(...args) { 15 | const packageJSON = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'))); 16 | if (!args.length) { 17 | return packageJSON; 18 | } 19 | return args.reduce((out, key) => { 20 | out[key] = packageJSON[key]; 21 | return out; 22 | }, {}); 23 | }; 24 | 25 | module.exports = getPackageJson; -------------------------------------------------------------------------------- /scripts/testMock.js: -------------------------------------------------------------------------------- 1 | module.exports = {}; -------------------------------------------------------------------------------- /src/TarotWidget.js: -------------------------------------------------------------------------------- 1 | import cardStateStorage from "./actions/cardStateStorage"; 2 | import renderWidgetHtml from "./actions/renderWidgetHtml"; 3 | import cardsMap from "./cards-map.json"; 4 | 5 | class TarotWidget { 6 | constructor( 7 | containerId = "mo-tarot-widget", 8 | cardStateStorageLib = cardStateStorage, 9 | renderFn = renderWidgetHtml 10 | ) { 11 | this.containerId = containerId; 12 | this.el = document.getElementById(containerId); 13 | this.cardStateStorageLib = cardStateStorageLib; 14 | this.renderFn = renderFn; 15 | this.cardsMap = cardsMap; 16 | 17 | try { 18 | this.mount(); 19 | } catch (err) { 20 | console.log(err); 21 | } 22 | } 23 | 24 | mount() { 25 | let cardOfTheDayID = this.cardStateStorageLib.getCard(); 26 | 27 | if (!cardOfTheDayID) { 28 | cardOfTheDayID = this.getRandomCardID(); 29 | this.cardStateStorageLib.saveCard(cardOfTheDayID); 30 | } 31 | 32 | const cardData = this.cardsMap[cardOfTheDayID]; 33 | 34 | if (cardData) { 35 | this.el.innerHTML = this.renderFn( 36 | Object.assign({}, cardData, { id: cardOfTheDayID }) 37 | ); 38 | } 39 | } 40 | 41 | getRandomCardID() { 42 | const ids = Object.keys(this.cardsMap); 43 | 44 | const randomIndex = Math.floor(Math.random() * ids.length); 45 | 46 | return ids[randomIndex]; 47 | } 48 | } 49 | 50 | export default TarotWidget; 51 | -------------------------------------------------------------------------------- /src/actions/cardStateStorage.js: -------------------------------------------------------------------------------- 1 | import Cookies from "js-cookie"; 2 | 3 | const COOKIES_KEY = "mo-tarot-widget-card-of-the-day"; 4 | 5 | function getCard() { 6 | return Cookies.get(COOKIES_KEY); 7 | } 8 | 9 | function saveCard(cardId) { 10 | Cookies.set(COOKIES_KEY, cardId, { expires: 1 }); 11 | } 12 | 13 | export default { 14 | getCard, 15 | saveCard, 16 | }; 17 | -------------------------------------------------------------------------------- /src/actions/renderWidgetHtml.js: -------------------------------------------------------------------------------- 1 | import config from "../config.json"; 2 | 3 | export default function (cardData) { 4 | return ` 5 |
6 |
${config.widgetTitle}
7 |
${config.widgetSubtitle}
8 |
9 | 10 |
11 |
${cardData.desc}
12 | 15 |
16 | `; 17 | } 18 | -------------------------------------------------------------------------------- /src/automount.js: -------------------------------------------------------------------------------- 1 | import "./index.css"; 2 | import TarotWidget from "./TarotWidget"; 3 | 4 | new TarotWidget(); 5 | -------------------------------------------------------------------------------- /src/cards-map.json: -------------------------------------------------------------------------------- 1 | { 2 | "the-fool": { 3 | "name": "The Fool", 4 | "desc": "Boldly step into the unknown!" 5 | }, 6 | "the-magician": { 7 | "name": "The Magician", 8 | "desc": "It's time to manifest intentions!" 9 | }, 10 | "the-high-priestess": { 11 | "name": "The High Priestess", 12 | "desc": "Wait for clarity!" 13 | }, 14 | "the-empress": { 15 | "name": "The Empress", 16 | "desc": "Enjoy the abundance!" 17 | }, 18 | "the-emperor": { 19 | "name": "The Emperor", 20 | "desc": "Go for it with persistence and discipline." 21 | }, 22 | "the-hierophant": { 23 | "name": "The Hierophant", 24 | "desc": "Find a mentor and listen attentively." 25 | }, 26 | "the-lovers": { 27 | "name": "The Lovers", 28 | "desc": "Сhoose with your heart." 29 | }, 30 | "the-chariot": { 31 | "name": "The Chariot", 32 | "desc": "The war is over, and you are the winner!" 33 | }, 34 | "strength": { 35 | "name": "Strength", 36 | "desc": "Tame your instincts and use them." 37 | }, 38 | "the-hermit": { 39 | "name": "The Hermit", 40 | "desc": "Take time to explore yourself." 41 | }, 42 | "wheel-of-fortune": { 43 | "name": "Wheel of Fortune", 44 | "desc": "You'll get lucky!" 45 | }, 46 | "justice": { 47 | "name": "Justice", 48 | "desc": "Get what you deserve: reward or retribution?" 49 | }, 50 | "the-hanged-man": { 51 | "name": "The Hanged Man", 52 | "desc": "Look at the situation from a different angle." 53 | }, 54 | "death": { 55 | "name": "Death", 56 | "desc": "Let go of what no longer serves you." 57 | }, 58 | "temperance": { 59 | "name": "Temperance", 60 | "desc": "Be patient: your wishes are about to come true." 61 | }, 62 | "the-devil": { 63 | "name": "The Devil", 64 | "desc": "Warning! Resist temptation!" 65 | }, 66 | "the-tower": { 67 | "name": "The Tower", 68 | "desc": "Whatever happens, happens for the best." 69 | }, 70 | "the-star": { 71 | "name": "The Star", 72 | "desc": "Your cherished dream comes true!" 73 | }, 74 | "the-moon": { 75 | "name": "The Moon", 76 | "desc": "Try to find the truth among illusions." 77 | }, 78 | "the-sun": { 79 | "name": "The Sun", 80 | "desc": "Happiness is here and now!" 81 | }, 82 | "judgement": { 83 | "name": "Judgement", 84 | "desc": "Say Yes to change - it will bring you happiness." 85 | }, 86 | "the-world": { 87 | "name": "The World", 88 | "desc": "And they lived happily ever after!" 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "widgetDomain": "https://tarot-widget.moonorganizer.com", 3 | "widgetTitle": "Major Arcana of the Day", 4 | "widgetSubtitle": "Raider Waite Tarot Deck", 5 | "destinationLink": "https://moonorganizer.com/en/tarot-card-major-arcana-meaning/", 6 | "destinationLinkText": "Learn more about this card" 7 | } 8 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | .mo-tarot-widget { 2 | width: 250px; 3 | display: flex; 4 | flex-direction: column; 5 | align-items: center; 6 | text-align: center; 7 | font-family: Helvetica, sans-serif; 8 | line-height: 1.2; 9 | } 10 | 11 | .mo-tarot-widget__title { 12 | font-weight: bold; 13 | font-size: 21px; 14 | } 15 | 16 | .mo-tarot-widget__subtitle { 17 | font-weight: normal; 18 | font-size: 20px; 19 | margin: 3px 0; 20 | } 21 | 22 | .mo-tarot-widget__img { 23 | width: 90%; 24 | } 25 | .mo-tarot-widget__img img { 26 | width: 100%; 27 | } 28 | 29 | .mo-tarot-widget__desc { 30 | font-weight: normal; 31 | font-size: 18px; 32 | margin: 3px 0; 33 | } 34 | 35 | .mo-tarot-widget__link a { 36 | text-decoration: underline; 37 | font-size: 16px; 38 | } 39 | 40 | .mo-tarot-widget__link a:link, 41 | .mo-tarot-widget__link a:visited { 42 | color: inherit; 43 | text-decoration: underline; 44 | } 45 | 46 | .mo-tarot-widget__link a:hover, 47 | .mo-tarot-widget__link a:active { 48 | color: #0000ee; 49 | text-decoration: underline; 50 | } 51 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import "./index.css"; 2 | import TarotWidget from "./TarotWidget"; 3 | 4 | export default TarotWidget; 5 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const webpack = require('webpack'); 3 | const PrettierPlugin = require("prettier-webpack-plugin"); 4 | const TerserPlugin = require('terser-webpack-plugin'); 5 | const getPackageJson = require('./scripts/getPackageJson'); 6 | 7 | const { 8 | version, 9 | name, 10 | license, 11 | repository, 12 | author, 13 | } = getPackageJson('version', 'name', 'license', 'repository', 'author'); 14 | 15 | const banner = ` 16 | ${name} v${version} 17 | ${repository.url} 18 | 19 | Copyright (c) ${author.replace(/ *\<[^)]*\> */g, " ")} 20 | 21 | This source code is licensed under the ${license} license found in the 22 | LICENSE file in the root directory of this source tree. 23 | `; 24 | 25 | module.exports = { 26 | mode: "production", 27 | entry: { 28 | index: './src/index.js', 29 | automount: './src/automount.js', 30 | }, 31 | output: { 32 | filename: '[name].min.js', 33 | path: path.resolve(__dirname, 'build'), 34 | library: 'TarotWidget', 35 | libraryTarget: 'umd' 36 | }, 37 | optimization: { 38 | minimize: true, 39 | minimizer: [new TerserPlugin({ 40 | extractComments: false 41 | })], 42 | }, 43 | module: { 44 | rules: [ 45 | { 46 | test: /\.m?js$/, 47 | exclude: /(node_modules|bower_components)/, 48 | use: { 49 | loader: 'babel-loader' 50 | } 51 | }, 52 | { 53 | test: /\.css$/i, 54 | use: ['style-loader', 'css-loader'], 55 | }, 56 | { 57 | test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/, 58 | use: ['url-loader'], 59 | } 60 | ] 61 | }, 62 | plugins: [ 63 | new PrettierPlugin(), 64 | new webpack.BannerPlugin(banner) 65 | ] 66 | }; --------------------------------------------------------------------------------