UNPKG

npm-allakando-publish

Version:

Allakando's web component library

92 lines (89 loc) 2.34 kB
import resolve from "@rollup/plugin-node-resolve" import commonjs from "@rollup/plugin-commonjs" import pkg from "./package.json" import scss from "rollup-plugin-scss" import { string } from "rollup-plugin-string" import copy from "rollup-plugin-copy" import serve from "rollup-plugin-serve" import livereload from "rollup-plugin-livereload" import fs from "fs" import sass from "sass" const DIST_FOLDER = "development" const HTML_TEST_FILE = "index.html" const LIBRARY_NAME = pkg.name const EXPORT_NAME = "AllakandoWebUI" const VERSION = pkg.version const AUTHOR = pkg.author const DESCRIPTION = pkg.description const BANNER = `/** @preserve @license @cc_on * ---------------------------------------------------------- * ${LIBRARY_NAME} version ${VERSION} * ${DESCRIPTION} * Copyright (c) ${new Date().getFullYear()} ${AUTHOR} * All Rights Reserved. MIT License * https://mit-license.org/ * ---------------------------------------------------------- */\n` export default { input: "./src/index.bundle.js", output: [ { file: `${DIST_FOLDER}/bundle.js`, name: EXPORT_NAME, format: "umd", banner: BANNER, sourcemap: "inline" } ], plugins: [ resolve({ extensions: [".js"] }), commonjs(), scss({ output: false, outputStyle: "compressed" }), string({ include: ["**/*.html"] }), copy({ targets: [ { src: `src/${HTML_TEST_FILE}`, dest: `${DIST_FOLDER}/`, rename: "index.html", transform: content => content.toString().replace("<head>", `<head><script src="./bundle.js"></script><link rel="stylesheet" href="./bundle.css">`) }, { src: "src/Assets/Icons", dest: `${DIST_FOLDER}/` } ], copyOnce: true }), { name: "build-stylesheets", buildEnd() { fs.mkdirSync(`${DIST_FOLDER}/css`, { recursive: true }) fs.readdirSync("./src/Assets/Stylesheets/Global/").map(fileName => { const css = sass.compile(`./src/Assets/Stylesheets/Global/${fileName}`, { style: "compressed", sourceMap: false }) fs.writeFileSync(`${DIST_FOLDER}/${fileName.replace(/.scss$/, "")}.css`, `${BANNER}${css.css}`, "utf-8") }) return null } }, serve({ open: true, openPage: "/index.html", contentBase: ["", `${DIST_FOLDER}`], port: "8099" }), livereload({ watch: `${DIST_FOLDER}` }) ] }