Skip to content

Instantly share code, notes, and snippets.

View Weiyuan-Lane's full-sized avatar
🐈
Code. Code! CODE! CODE!!!!!!

Weiyuan Liu Weiyuan-Lane

🐈
Code. Code! CODE! CODE!!!!!!
View GitHub Profile
@Weiyuan-Lane
Weiyuan-Lane / next.config.js
Created August 10, 2019 07:48
Development tools for Next configuration
const withSass = require('@zeit/next-sass');
const path = require('path');
const CompressionPlugin = require('compression-webpack-plugin');
module.exports = withSass({
webpack: function(config) {
config.module.rules.push(
{
test: /\.(jpe?g|png|gif|svg|ico)$/,
use: {
@Weiyuan-Lane
Weiyuan-Lane / next.config.js
Created August 10, 2019 09:08
Using compression-webpack-plugin with Next.js + webpack
const CompressionPlugin = require('compression-webpack-plugin');
module.exports = {
webpack: function(config) {
config.plugins.push(new CompressionPlugin());
return config;
}
});
@Weiyuan-Lane
Weiyuan-Lane / package.json
Created August 10, 2019 09:27
subpath-as-branch as a script instruction in package.json
{
"scripts": {
"publish": "subpath-as-branch --path dist --branch gh-pages"
}
}
@Weiyuan-Lane
Weiyuan-Lane / next.config.js
Last active August 11, 2019 10:14
Next.js config for build process with base path as asset prefix
const basePath = '/spa-github-page-template'; // or '' if basePath needs to be left unchanged
const webpackBasePath = process.env.SPA_EXP_BUILD === 'true' ? basePath : '';
module.exports = {
assetPrefix: webpackBasePath,
};
@Weiyuan-Lane
Weiyuan-Lane / BasePathLink.js
Created August 11, 2019 12:44
Wrapper for 'next/link' to introduce a base path
@Weiyuan-Lane
Weiyuan-Lane / next.config.js
Created August 11, 2019 12:47
Next.js config for inserting configuration environment variables on base path to use throughout the application
const basePath = '/spa-github-page-template'; // or '' if basePath needs to be left unchanged
const webpackBasePath = process.env.SPA_EXP_BUILD === 'true' ? basePath : '';
module.exports = {
publicRuntimeConfig: {
basePath: webpackBasePath,
},
};
@Weiyuan-Lane
Weiyuan-Lane / Home.js
Created August 11, 2019 12:52
Sample component using `BasePathLink`
import BasePathLink from 'BasePathLink';
export default function Home() {
return (
<div>
This is an empty page, to test this SPA.<br/>
You should just go <BasePathLink href='/'><a>home</a></BasePathLink><br/>
Or you can go <BasePathLink href='/deep'><a>deep</a></BasePathLink>
@Weiyuan-Lane
Weiyuan-Lane / cloudrun_v_appengineflex.md
Last active August 12, 2019 09:02
Common factors comparing between Cloud Run and App Engine Flex (USD)
Cloud Run App Engine Flex (us-central1) App Engine Flex (southamerica-east-1)
Pricing blocks (second) 0.1 1.0 1.0
$ Per vCPU-hour (USD) 0.0864 0.0526 0.079
$ Per Ram-hour (USD) 0.009 0.0071 0.011
@Weiyuan-Lane
Weiyuan-Lane / app.yaml
Created October 26, 2019 05:23
App Engine Configuration
runtime: nodejs10
instance_class: B1
manual_scaling:
instances: 1
handlers:
- url: /static
static_dir: static
- url: /public
static_dir: public