diff --git a/build/build.lib.js b/build/build.lib.mjs similarity index 88% rename from build/build.lib.js rename to build/build.lib.mjs index c47f24bf..23f72dea 100644 --- a/build/build.lib.js +++ b/build/build.lib.mjs @@ -1,5 +1,5 @@ -const { build } = require("vite"); -const getLibConfig = require("./vite.config.lib.provider"); +import { build } from "vite"; +import getLibConfig from "./vite.config.lib.provider.mjs"; const entries = [ "UiAlert", diff --git a/build/options.js b/build/options.js deleted file mode 100644 index 9c538c87..00000000 --- a/build/options.js +++ /dev/null @@ -1,35 +0,0 @@ -const path = require("path"); - -const version = require("./version"); - -const banner = - "/*!\n" + - " * Keen UI v" + - version + - " (https://github.com/JosephusPaye/keen-ui)\n" + - " * (c) " + - new Date().getFullYear() + - " Josephus Paye II\n" + - " * Released under the MIT License.\n" + - " */"; - -module.exports = { - banner, - - paths: { - src: { - main: path.join(__dirname, "..", "src"), - docs: path.join(__dirname, "..", "docs-src"), - }, - - output: { - main: path.join(__dirname, "..", "dist"), - lib: path.join(__dirname, "..", "lib"), - docs: path.join(__dirname, "..", "docs"), - }, - - resolve(location) { - return path.join(__dirname, "..", location); - }, - }, -}; diff --git a/build/options.mjs b/build/options.mjs new file mode 100644 index 00000000..bf381d19 --- /dev/null +++ b/build/options.mjs @@ -0,0 +1,39 @@ +import { join, dirname } from "path"; +import { fileURLToPath } from 'url'; + +import version from "./version.mjs"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const banner = + "/*!\n" + + " * Keen UI v" + + version + + " (https://github.com/JosephusPaye/keen-ui)\n" + + " * (c) " + + new Date().getFullYear() + + " Josephus Paye II\n" + + " * Released under the MIT License.\n" + + " */"; + +export default { + banner, + + paths: { + src: { + main: join(__dirname, "..", "src"), + docs: join(__dirname, "..", "docs-src"), + }, + + output: { + main: join(__dirname, "..", "dist"), + lib: join(__dirname, "..", "lib"), + docs: join(__dirname, "..", "docs"), + }, + + resolve(location) { + return join(__dirname, "..", location); + }, + }, +}; diff --git a/build/version.js b/build/version.mjs similarity index 83% rename from build/version.js rename to build/version.mjs index 61881e38..9945eeb0 100644 --- a/build/version.js +++ b/build/version.mjs @@ -1,3 +1,3 @@ // Hardcoding here (and not reading from package.json) as the files are built // before the version is updated in package.json -module.exports = "1.4.0"; +export default "1.4.0"; diff --git a/build/vite.config.dist.js b/build/vite.config.dist.mjs similarity index 82% rename from build/vite.config.dist.js rename to build/vite.config.dist.mjs index 519ed5e9..12916fa8 100644 --- a/build/vite.config.dist.js +++ b/build/vite.config.dist.mjs @@ -1,8 +1,9 @@ -const { defineConfig } = require("vite"); -const vue = require("@vitejs/plugin-vue"); -const banner = require("vite-plugin-banner"); -const options = require("./options"); -const autoprefixer = require("autoprefixer"); +import { defineConfig } from "vite"; +import vue from "@vitejs/plugin-vue"; +import banner from "vite-plugin-banner"; +import autoprefixer from "autoprefixer"; + +import options from "./options.mjs"; export default defineConfig(({ mode }) => { const filename = mode === "production" ? "keen-ui.min" : "keen-ui"; diff --git a/build/vite.config.docs.js b/build/vite.config.docs.mjs similarity index 76% rename from build/vite.config.docs.js rename to build/vite.config.docs.mjs index bf91f813..9bd8247f 100644 --- a/build/vite.config.docs.js +++ b/build/vite.config.docs.mjs @@ -1,8 +1,9 @@ -const { fileURLToPath, URL } = require("url"); -const { defineConfig } = require("vite"); -const vue = require("@vitejs/plugin-vue"); -const options = require("./options"); -const autoprefixer = require("autoprefixer"); +import { fileURLToPath, URL } from "url"; +import { defineConfig } from "vite"; +import vue from "@vitejs/plugin-vue"; +import autoprefixer from "autoprefixer"; + +import options from "./options.mjs"; export default defineConfig({ plugins: [vue()], diff --git a/build/vite.config.lib.provider.js b/build/vite.config.lib.provider.mjs similarity index 78% rename from build/vite.config.lib.provider.js rename to build/vite.config.lib.provider.mjs index cbaf4fbd..a8626b6f 100644 --- a/build/vite.config.lib.provider.js +++ b/build/vite.config.lib.provider.mjs @@ -1,9 +1,10 @@ -const vue = require("@vitejs/plugin-vue"); -const banner = require("vite-plugin-banner"); -const options = require("./options"); -const autoprefixer = require("autoprefixer"); +import vue from "@vitejs/plugin-vue"; +import banner from "vite-plugin-banner"; +import autoprefixer from "autoprefixer"; -module.exports = ({ entry, mode }) => { +import options from "./options.mjs"; + +export default ({ entry, mode }) => { const outDir = options.paths.output.lib; return { diff --git a/docs-src/App.vue b/docs-src/App.vue index 4216101e..efb76769 100644 --- a/docs-src/App.vue +++ b/docs-src/App.vue @@ -38,7 +38,7 @@ import DocsNavbar from "./DocsNavbar.vue"; import DocsSidebar from "./DocsSidebar.vue"; -import version from "../build/version"; +import version from "../build/version.mjs"; export default { components: { diff --git a/package.json b/package.json index 925ab236..a90ec04c 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,12 @@ "description": "Keen UI is a Vue.js UI library with a simple API, inspired by Google's Material Design.", "main": "dist/keen-ui.js", "scripts": { - "dev": "vite serve --config build/vite.config.docs.js docs-src", - "build:dist": "vite build --config build/vite.config.dist.js --mode development", - "build:dist:prod": "vite build --config build/vite.config.dist.js", - "build:lib": "cross-env NODE_ENV=development node build/build.lib.js", - "build:lib:prod": "node build/build.lib.js", - "build:docs": "vite build --config build/vite.config.docs.js docs-src", + "dev": "vite serve --config build/vite.config.docs.mjs docs-src", + "build:dist": "vite build --config build/vite.config.dist.mjs --mode development", + "build:dist:prod": "vite build --config build/vite.config.dist.mjs", + "build:lib": "cross-env NODE_ENV=development node build/build.lib.mjs", + "build:lib:prod": "node build/build.lib.mjs", + "build:docs": "vite build --config build/vite.config.docs.mjs docs-src", "build:all": "npm run build:dist && npm run build:lib && npm run build:docs", "build:all:prod": "npm run build:dist:prod && npm run build:lib:prod && npm run build:docs", "clean": "rimraf ./dist ./lib ./docs",