mirror of
https://github.com/aleleba/create-react-ssr.git
synced 2025-01-09 13:36:54 -06:00
Changing some files to typescript and fixing webpack build.
This commit is contained in:
parent
1c5117f6d4
commit
0645d471bb
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@aleleba/create-react-ssr",
|
"name": "@aleleba/create-react-ssr",
|
||||||
"version": "2.0.1",
|
"version": "2.0.3",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@aleleba/create-react-ssr",
|
"name": "@aleleba/create-react-ssr",
|
||||||
"version": "2.0.1",
|
"version": "2.0.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/register": "^7.17.7",
|
"@babel/register": "^7.17.7",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@aleleba/create-react-ssr",
|
"name": "@aleleba/create-react-ssr",
|
||||||
"version": "2.0.3",
|
"version": "2.0.4",
|
||||||
"description": "Starter Kit of server side render of react",
|
"description": "Starter Kit of server side render of react",
|
||||||
"bin": "./bin/cli.js",
|
"bin": "./bin/cli.js",
|
||||||
"main": "src/server/index",
|
"main": "src/server/index",
|
||||||
|
@ -4,7 +4,7 @@ const getHashManifest = () => {
|
|||||||
try {
|
try {
|
||||||
const baseUrl = __dirname.replace(/\/server(.*)/,'');
|
const baseUrl = __dirname.replace(/\/server(.*)/,'');
|
||||||
const fullURL = `${baseUrl}/assets/manifest-hash.json` ;
|
const fullURL = `${baseUrl}/assets/manifest-hash.json` ;
|
||||||
return JSON.parse(fs.readFileSync(fullURL));
|
return JSON.parse(fs.readFileSync(fullURL).toString());
|
||||||
}catch(err){
|
}catch(err){
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
@ -2,8 +2,6 @@ require('dotenv').config();
|
|||||||
|
|
||||||
require('ignore-styles');
|
require('ignore-styles');
|
||||||
|
|
||||||
//require('webpack-node-externals')();
|
|
||||||
|
|
||||||
require('@babel/register')({
|
require('@babel/register')({
|
||||||
'presets': [
|
'presets': [
|
||||||
['@babel/preset-env', {'targets': {'node': 'current'}}],
|
['@babel/preset-env', {'targets': {'node': 'current'}}],
|
@ -15,11 +15,11 @@
|
|||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
"isolatedModules": false,
|
||||||
"types": [
|
"types": [
|
||||||
"react/next",
|
"react/next",
|
||||||
"react-dom/next",
|
"react-dom/next",
|
||||||
|
@ -14,7 +14,7 @@ module.exports = {
|
|||||||
mode: 'development',
|
mode: 'development',
|
||||||
name: 'server',
|
name: 'server',
|
||||||
entry: {
|
entry: {
|
||||||
server: `${ROOT_DIR}/src/server/index.js`,
|
server: `${ROOT_DIR}/src/server/index.ts`,
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
|
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
|
||||||
|
@ -9,16 +9,19 @@ const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
|
|||||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||||
const ESLintPlugin = require('eslint-webpack-plugin');
|
const ESLintPlugin = require('eslint-webpack-plugin');
|
||||||
const CopyPlugin = require('copy-webpack-plugin');
|
const CopyPlugin = require('copy-webpack-plugin');
|
||||||
|
const ROOT_DIR = path.resolve(__dirname);
|
||||||
|
const resolvePath = (...args) => path.resolve(ROOT_DIR, ...args);
|
||||||
|
const BUILD_DIR = resolvePath('build');
|
||||||
const { InjectManifest } = require('workbox-webpack-plugin');
|
const { InjectManifest } = require('workbox-webpack-plugin');
|
||||||
const nodeExternals = require('webpack-node-externals');
|
const nodeExternals = require('webpack-node-externals');
|
||||||
const PUBLIC_URL = process.env.PUBLIC_URL || '/';
|
const PUBLIC_URL = process.env.PUBLIC_URL || '/';
|
||||||
|
|
||||||
const frontendConfig = {
|
const frontendConfig = {
|
||||||
entry: {
|
entry: {
|
||||||
frontend: './src/frontend/index.tsx',
|
frontend: `${ROOT_DIR}/src/frontend/index.tsx`,
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, 'build'),
|
path: BUILD_DIR,
|
||||||
filename: 'assets/app-[name]-[fullhash].js',
|
filename: 'assets/app-[name]-[fullhash].js',
|
||||||
publicPath: PUBLIC_URL,
|
publicPath: PUBLIC_URL,
|
||||||
},
|
},
|
||||||
@ -89,16 +92,16 @@ const frontendConfig = {
|
|||||||
new CopyPlugin({
|
new CopyPlugin({
|
||||||
patterns: [
|
patterns: [
|
||||||
{
|
{
|
||||||
from: './public/manifest.json', to: '',
|
from: `${ROOT_DIR}/public/manifest.json`, to: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
from: './public/favicon.ico', to: '',
|
from: `${ROOT_DIR}/public/favicon.ico`, to: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
from: './public/logo192.png', to: '',
|
from: `${ROOT_DIR}/public/logo192.png`, to: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
from: './public/logo512.png', to: '',
|
from: `${ROOT_DIR}/public/logo512.png`, to: '',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
@ -135,7 +138,7 @@ const frontendConfig = {
|
|||||||
|
|
||||||
const serverConfig = {
|
const serverConfig = {
|
||||||
entry: {
|
entry: {
|
||||||
server: './src/server/index.js',
|
server: './src/server/index.ts',
|
||||||
},
|
},
|
||||||
target: "node",
|
target: "node",
|
||||||
externals: [nodeExternals()],
|
externals: [nodeExternals()],
|
||||||
@ -234,4 +237,4 @@ const serverConfig = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = [frontendConfig, serverConfig];
|
module.exports = [frontendConfig, serverConfig];
|
||||||
|
Loading…
Reference in New Issue
Block a user