mirror of
https://github.com/morten-olsen/morten-olsen.github.io.git
synced 2026-02-08 01:46:28 +01:00
cleanup
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
import vm from "vm";
|
||||
import React, { ComponentType } from "react";
|
||||
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
||||
import commonjs from "@rollup/plugin-commonjs";
|
||||
import json from "@rollup/plugin-json";
|
||||
import replace from "@rollup/plugin-replace";
|
||||
import sucrase from "@rollup/plugin-sucrase";
|
||||
import alias from "@rollup/plugin-alias";
|
||||
import externalGlobals from "rollup-plugin-external-globals";
|
||||
import { createScript } from "../script";
|
||||
import orgStyled from "styled-components";
|
||||
import * as styledExports from "styled-components";
|
||||
import ReactHelmetAsync from "react-helmet-async";
|
||||
import { resolve } from "path";
|
||||
import vm from 'vm';
|
||||
import React, { ComponentType } from 'react';
|
||||
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import json from '@rollup/plugin-json';
|
||||
import replace from '@rollup/plugin-replace';
|
||||
import sucrase from '@rollup/plugin-sucrase';
|
||||
import alias from '@rollup/plugin-alias';
|
||||
import externalGlobals from 'rollup-plugin-external-globals';
|
||||
import { createScript } from '../script';
|
||||
import orgStyled from 'styled-components';
|
||||
import * as styledExports from 'styled-components';
|
||||
import ReactHelmetAsync from 'react-helmet-async';
|
||||
import { resolve } from 'path';
|
||||
|
||||
const styled = orgStyled.bind(null);
|
||||
for (let key of Object.keys(orgStyled)) {
|
||||
if (key === "default") {
|
||||
if (key === 'default') {
|
||||
continue;
|
||||
}
|
||||
(styled as any)[key] = (orgStyled as any)[key];
|
||||
}
|
||||
for (let key of Object.keys(styledExports)) {
|
||||
if (key === "default") {
|
||||
if (key === 'default') {
|
||||
continue;
|
||||
}
|
||||
(styled as any)[key] = (styledExports as any)[key];
|
||||
@@ -30,34 +30,32 @@ for (let key of Object.keys(styledExports)) {
|
||||
const createReact = <TProps = any>(path: string) => {
|
||||
const script = createScript({
|
||||
path,
|
||||
format: "cjs",
|
||||
format: 'cjs',
|
||||
plugins: [
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
"process.env.NODE_ENV": JSON.stringify("production"),
|
||||
'process.env.NODE_ENV': JSON.stringify('production'),
|
||||
}),
|
||||
alias({
|
||||
entries: [
|
||||
{ find: "@", replacement: resolve("content/templates/react") },
|
||||
],
|
||||
entries: [{ find: '@', replacement: resolve('content/templates/react') }],
|
||||
}),
|
||||
sucrase({
|
||||
exclude: ["node_modules/**"],
|
||||
transforms: ["jsx", "typescript"],
|
||||
exclude: ['node_modules/**'],
|
||||
transforms: ['jsx', 'typescript'],
|
||||
}),
|
||||
nodeResolve({
|
||||
browser: true,
|
||||
preferBuiltins: false,
|
||||
extensions: [".js", ".ts", ".tsx"],
|
||||
extensions: ['.js', '.ts', '.tsx'],
|
||||
}),
|
||||
json(),
|
||||
commonjs({
|
||||
include: /node_modules/,
|
||||
}),
|
||||
externalGlobals({
|
||||
react: "React",
|
||||
"styled-components": "StyledComponents",
|
||||
"react-helmet-async": "ReactHelmetAsync",
|
||||
react: 'React',
|
||||
'styled-components': 'StyledComponents',
|
||||
'react-helmet-async': 'ReactHelmetAsync',
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user