Skip to content

Commit

Permalink
build docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mistlog committed Dec 27, 2020
1 parent d1c1043 commit 87040ce
Show file tree
Hide file tree
Showing 8 changed files with 11,554 additions and 11,497 deletions.
22,800 changes: 11,419 additions & 11,381 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "svelte-element",
"version": "0.0.3",
"version": "0.0.4",
"description": "Element UI in svelte",
"author": "mistlog",
"license": "MIT",
Expand Down Expand Up @@ -34,14 +34,15 @@
"type": "git",
"url": "https://github.com/mistlog/svelte-element"
},
"homepage": "https://github.com/mistlog/svelte-element",
"homepage": "https://mistlog.github.io/svelte-element/",
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
"@babel/plugin-transform-typescript": "^7.11.0",
"@babel/preset-env": "^7.11.5",
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-replace": "^2.3.4",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/svelte": "^3.0.0",
"@types/jest": "^26.0.13",
Expand Down
65 changes: 35 additions & 30 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />

<title>Svelte Element</title>
<title>Svelte Element</title>

<link rel='icon' type='image/png' href='/favicon.ico'>
<link rel='stylesheet' href='/css/element-vue/element-ui@2.14.1.css'>
<link rel='stylesheet' href='/global.css'>
<link rel='stylesheet' href='/prism-theme-vs-dark.css'>
<link rel='stylesheet' href='/build/bundle.css'>
<link rel="icon" type="image/png" href="./favicon.ico" />
<link rel="stylesheet" href="./css/element-vue/element-ui@2.14.1.css" />
<link rel="stylesheet" href="./global.css" />
<link rel="stylesheet" href="./prism-theme-vs-dark.css" />
<link rel="stylesheet" href="./build/bundle.css" />

<script src='/lib/svelte-draft/index.js'></script>
<script defer src='/build/bundle.js'></script>
</head>
<script src="./lib/svelte-draft/index.js"></script>
<script defer src="./build/bundle.js"></script>
</head>

<body>
<script>
// credit: https://www.smashingmagazine.com/2016/08/sghpa-single-page-app-hack-github-pages
(function(){
var redirect = sessionStorage.redirect;
delete sessionStorage.redirect;
if (redirect && redirect != location.href) {
history.replaceState(null, null, redirect);
// REMOVE THIS - just showing the redirect route in the UI
document.body.setAttribute('message', 'This page was redirected by 404.html, from the route: ' + redirect);
}
else {
// REMOVE THIS - just showing the redirect route in the UI
document.body.setAttribute('message', 'This page was loaded directly from the index.html file');
}
})();
</script>
</body>
<body>
<script>
// credit: https://www.smashingmagazine.com/2016/08/sghpa-single-page-app-hack-github-pages
(function () {
var redirect = sessionStorage.redirect;
delete sessionStorage.redirect;
if (redirect && redirect != location.href) {
history.replaceState(null, null, redirect);
// REMOVE THIS - just showing the redirect route in the UI
document.body.setAttribute(
"message",
"This page was redirected by 404.html, from the route: " + redirect
);
} else {
// REMOVE THIS - just showing the redirect route in the UI
document.body.setAttribute(
"message",
"This page was loaded directly from the index.html file"
);
}
})();
</script>
</body>
</html>
161 changes: 83 additions & 78 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,95 +1,100 @@
import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import svelte_draft from 'rollup-plugin-svelte-draft';
import globals from 'rollup-plugin-node-globals';
import svelte from "rollup-plugin-svelte";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import livereload from "rollup-plugin-livereload";
import { terser } from "rollup-plugin-terser";
import svelte_draft from "rollup-plugin-svelte-draft";
import globals from "rollup-plugin-node-globals";
import { string } from "rollup-plugin-string";
import { mdsvex } from "mdsvex";
import draftConfig from "./svelte-draft.config";
import replace from "@rollup/plugin-replace";

const production = !process.env.ROLLUP_WATCH;

export default {
input: 'src/main.ts',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js',
globals: {
"svelte-draft": 'SvelteDraft'
}
},
external: ['svelte-draft'],
plugins: [
string({
// Required to be specified
include: "**/*.snippet"
}),
svelte_draft({
include: ["./src/**/*.tsx", "./src/**/*.ts"], config: draftConfig
}),
svelte({
extensions: [".tsx", ".svelte", ".svx"],
preprocess: mdsvex({
layout: {
docs: "./src/site/docs/layout/docs.svelte"
}
}),
exclude: "./src/**/*.js.tsx",
// enable run-time checks when not in production
dev: !production,
// we'll extract any component CSS out into
// a separate file — better for performance
css: css => {
css.write('public/build/bundle.css');
}
}),
input: "src/main.ts",
output: {
sourcemap: true,
format: "iife",
name: "app",
file: "public/build/bundle.js",
globals: {
"svelte-draft": "SvelteDraft"
}
},
external: ["svelte-draft"],
plugins: [
replace({
__BuildEnv__: production ? JSON.stringify("prod") : JSON.stringify("dev")
}),
string({
// Required to be specified
include: "**/*.snippet"
}),
svelte_draft({
include: ["./src/**/*.tsx", "./src/**/*.ts"],
config: draftConfig
}),
svelte({
extensions: [".tsx", ".svelte", ".svx"],
preprocess: mdsvex({
layout: {
docs: "./src/site/docs/layout/docs.svelte"
}
}),
exclude: "./src/**/*.js.tsx",
// enable run-time checks when not in production
dev: !production,
// we'll extract any component CSS out into
// a separate file — better for performance
css: css => {
css.write("public/build/bundle.css");
}
}),

// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration —
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ['svelte']
}),
commonjs(),
globals(),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration —
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ["svelte"]
}),
commonjs(),
globals(),

// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),

// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload('public'),
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload("public"),

// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
],
watch: {
clearScreen: false
}
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
],
watch: {
clearScreen: false
}
};

function serve() {
let started = false;
let started = false;

return {
writeBundle() {
if (!started) {
started = true;
return {
writeBundle() {
if (!started) {
started = true;

require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
});
}
}
};
require("child_process").spawn("npm", ["run", "start", "--", "--dev"], {
stdio: ["ignore", "inherit", "inherit"],
shell: true
});
}
}
};
}
14 changes: 11 additions & 3 deletions src/site/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@ export default function _() {
const resolveComponentName = (location: { pathname: string }) => {
const segments = location.pathname.split("/");
const name = segments[segments.length - 1];
// TODO, change it to name === "" || name === "svelte-element"

//@ts-ignore
if (__BuildEnv__ === "prod") {
return name === "" || name === "svelte-element" ? "overview" : name;
}

return name === "" ? "overview" : name;
};

// TODO, change it to /svelte-element
const basepath = "/";
let basepath = "/";

//@ts-ignore
if (__BuildEnv__ === "prod") {
basepath = "/svelte-element";
}

const style = {
sidebar: {
Expand Down
2 changes: 1 addition & 1 deletion src/site/docs/component/h1.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Title from "./title";
import Title from "./Title";

export default function _() {
<h1>
Expand Down
2 changes: 1 addition & 1 deletion src/site/docs/component/h2.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Title from "./title";
import Title from "./Title";

export default function _() {
<h2>
Expand Down
2 changes: 1 addition & 1 deletion src/site/docs/component/h3.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Title from "./title";
import Title from "./Title";

export default function _() {
<h3>
Expand Down

0 comments on commit 87040ce

Please sign in to comment.