-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 7131628.
- Loading branch information
Showing
15 changed files
with
576 additions
and
973 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
.DS_Store | ||
/node_modules | ||
node_modules | ||
yarn-error.log | ||
/cypress/screenshots/ | ||
/.svelte-kit | ||
/__sapper__/ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
import 'prismjs'; | ||
import "prism-svelte"; | ||
import "./prism/svx.js"; | ||
|
||
|
||
|
||
import resolve from "@rollup/plugin-node-resolve"; | ||
import replace from "@rollup/plugin-replace"; | ||
import commonjs from "@rollup/plugin-commonjs"; | ||
import svelte from "rollup-plugin-svelte"; | ||
import babel from "@rollup/plugin-babel"; | ||
import { terser } from "rollup-plugin-terser"; | ||
import config from "sapper/config/rollup.js"; | ||
import pkg from "./package.json"; | ||
|
||
import slug from "rehype-slug"; | ||
import link from "rehype-autolink-headings"; | ||
|
||
import { highlight, highlighter } from "./prism/prism.js"; | ||
|
||
import { extname } from "path"; | ||
|
||
const mode = process.env.NODE_ENV; | ||
const dev = mode === "development"; | ||
const legacy = !!process.env.SAPPER_LEGACY_BUILD; | ||
|
||
import { mdsvex } from "mdsvex"; | ||
|
||
function mdsvex_transform() { | ||
return { | ||
async transform(code, id) { | ||
if (extname(id) !== ".svtext") return; | ||
|
||
const c = ( | ||
await mdsvex({ | ||
highlight: { | ||
alias: { | ||
ts: "typescript", | ||
mdx: "markdown", | ||
svelte: "svelte", | ||
svx: "svx", | ||
mdsvex: "svx", | ||
sig: "ts", | ||
} | ||
}, | ||
extension: '.svtext', | ||
rehypePlugins: [slug, link] | ||
}).markup({ content: code, filename: id }) | ||
).code; | ||
return `export default \`${c.replace(/`/g, "\\`").trim()}\`;`; | ||
} | ||
}; | ||
} | ||
|
||
export default { | ||
client: { | ||
input: config.client.input(), | ||
output: config.client.output(), | ||
globals: { | ||
global: "window" | ||
}, | ||
plugins: [ | ||
replace({ | ||
"process.browser": true, | ||
"process.env.NODE_ENV": JSON.stringify(mode) | ||
}), | ||
mdsvex_transform(), | ||
svelte({ | ||
extensions: [".svelte", ".svx"], | ||
compilerOptions: { | ||
dev, | ||
hydratable: true | ||
}, | ||
emitCss: true, | ||
preprocess: mdsvex({ extension: '.svx' }) | ||
}), | ||
resolve({ preferBuiltins: false, browser: true }), | ||
commonjs(), | ||
|
||
legacy && | ||
babel({ | ||
extensions: [".js", ".mjs", ".html", ".svelte"], | ||
babelHelpers: "runtime", | ||
exclude: ["node_modules/@babel/**"], | ||
presets: [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
targets: "> 0.25%, not dead" | ||
} | ||
] | ||
], | ||
plugins: [ | ||
"@babel/plugin-syntax-dynamic-import", | ||
[ | ||
"@babel/plugin-transform-runtime", | ||
{ | ||
useESModules: true | ||
} | ||
] | ||
] | ||
}), | ||
|
||
!dev && | ||
terser({ | ||
module: true | ||
}) | ||
] | ||
}, | ||
|
||
server: { | ||
input: config.server.input(), | ||
output: config.server.output(), | ||
plugins: [ | ||
replace({ | ||
"process.browser": false, | ||
"process.env.NODE_ENV": JSON.stringify(mode) | ||
}), | ||
mdsvex_transform(), | ||
svelte({ | ||
extensions: [".svelte", ".svx"], | ||
compilerOptions: { | ||
generate: "ssr", | ||
dev | ||
}, | ||
preprocess: mdsvex({ extension: '.svx' }) | ||
}), | ||
resolve({ browser: true }), | ||
commonjs() | ||
], | ||
external: Object.keys(pkg.dependencies).concat( | ||
require("module").builtinModules || | ||
Object.keys(process.binding("natives")) | ||
) | ||
}, | ||
|
||
serviceworker: { | ||
input: config.serviceworker.input(), | ||
output: config.serviceworker.output(), | ||
plugins: [ | ||
resolve(), | ||
replace({ | ||
"process.browser": true, | ||
"process.env.NODE_ENV": JSON.stringify(mode) | ||
}), | ||
commonjs(), | ||
!dev && terser() | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as sapper from '@sapper/app'; | ||
|
||
sapper.start({ | ||
target: document.querySelector('#sapper') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import sirv from 'sirv'; | ||
import polka from 'polka'; | ||
import compression from 'compression'; | ||
import * as sapper from '@sapper/server'; | ||
|
||
const { PORT, NODE_ENV } = process.env; | ||
const dev = NODE_ENV === 'development'; | ||
|
||
polka() // You can also use Express | ||
.use( | ||
compression({ threshold: 0 }), | ||
sirv('static', { dev }), | ||
sapper.middleware() | ||
) | ||
.listen(PORT, err => { | ||
if (err) console.log('error', err); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// import { timestamp, files, shell, routes } from '@sapper/service-worker'; | ||
|
||
// const ASSETS = `cache${timestamp}`; | ||
|
||
// // `shell` is an array of all the files generated by the bundler, | ||
// // `files` is an array of everything in the `static` directory | ||
// const to_cache = shell.concat(files); | ||
// const cached = new Set(to_cache); | ||
|
||
// self.addEventListener('install', event => { | ||
// event.waitUntil( | ||
// caches | ||
// .open(ASSETS) | ||
// .then(cache => cache.addAll(to_cache)) | ||
// .then(() => { | ||
// self.skipWaiting(); | ||
// }) | ||
// ); | ||
// }); | ||
|
||
// self.addEventListener('activate', event => { | ||
// event.waitUntil( | ||
// caches.keys().then(async keys => { | ||
// // delete old caches | ||
// for (const key of keys) { | ||
// if (key !== ASSETS) await caches.delete(key); | ||
// } | ||
|
||
// self.clients.claim(); | ||
// }) | ||
// ); | ||
// }); | ||
|
||
// self.addEventListener('fetch', event => { | ||
// if (event.request.method !== 'GET' || event.request.headers.has('range')) return; | ||
|
||
// const url = new URL(event.request.url); | ||
|
||
// // don't try to handle e.g. data: URIs | ||
// if (!url.protocol.startsWith('http')) return; | ||
|
||
// // ignore dev server requests | ||
// if (url.hostname === self.location.hostname && url.port !== self.location.port) return; | ||
|
||
// // always serve static files and bundler-generated assets from cache | ||
// if (url.host === self.location.host && cached.has(url.pathname)) { | ||
// event.respondWith(caches.match(event.request)); | ||
// return; | ||
// } | ||
|
||
// // for pages, you might want to serve a shell `service-worker-index.html` file, | ||
// // which Sapper has generated for you. It's not right for every | ||
// // app, but if it's right for yours then uncomment this section | ||
// /* | ||
// if (url.origin === self.origin && routes.find(route => route.pattern.test(url.pathname))) { | ||
// event.respondWith(caches.match('/service-worker-index.html')); | ||
// return; | ||
// } | ||
// */ | ||
|
||
// if (event.request.cache === 'only-if-cached') return; | ||
|
||
// // for everything else, try the network first, falling back to | ||
// // cache if the user is offline. (If the pages never change, you | ||
// // might prefer a cache-first approach to a network-first one.) | ||
// event.respondWith( | ||
// caches | ||
// .open(`offline${timestamp}`) | ||
// .then(async cache => { | ||
// try { | ||
// const response = await fetch(event.request); | ||
// cache.put(event.request, response.clone()); | ||
// return response; | ||
// } catch(err) { | ||
// const response = await cache.match(event.request); | ||
// if (response) return response; | ||
|
||
// throw err; | ||
// } | ||
// }) | ||
// ); | ||
// }); |
Oops, something went wrong.