mirror of
https://github.com/aleleba/create-react-ssr.git
synced 2025-01-09 05:26:58 -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",
|
||||
"version": "2.0.1",
|
||||
"version": "2.0.3",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@aleleba/create-react-ssr",
|
||||
"version": "2.0.1",
|
||||
"version": "2.0.3",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/register": "^7.17.7",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@aleleba/create-react-ssr",
|
||||
"version": "2.0.3",
|
||||
"version": "2.0.4",
|
||||
"description": "Starter Kit of server side render of react",
|
||||
"bin": "./bin/cli.js",
|
||||
"main": "src/server/index",
|
||||
|
@ -4,7 +4,7 @@ const getHashManifest = () => {
|
||||
try {
|
||||
const baseUrl = __dirname.replace(/\/server(.*)/,'');
|
||||
const fullURL = `${baseUrl}/assets/manifest-hash.json` ;
|
||||
return JSON.parse(fs.readFileSync(fullURL));
|
||||
return JSON.parse(fs.readFileSync(fullURL).toString());
|
||||
}catch(err){
|
||||
console.error(err);
|
||||
}
|
@ -2,8 +2,6 @@ require('dotenv').config();
|
||||
|
||||
require('ignore-styles');
|
||||
|
||||
//require('webpack-node-externals')();
|
||||
|
||||
require('@babel/register')({
|
||||
'presets': [
|
||||
['@babel/preset-env', {'targets': {'node': 'current'}}],
|
@ -15,11 +15,11 @@
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": false,
|
||||
"jsx": "react-jsx",
|
||||
"experimentalDecorators": true,
|
||||
"esModuleInterop": true,
|
||||
"isolatedModules": false,
|
||||
"types": [
|
||||
"react/next",
|
||||
"react-dom/next",
|
||||
|
@ -14,7 +14,7 @@ module.exports = {
|
||||
mode: 'development',
|
||||
name: 'server',
|
||||
entry: {
|
||||
server: `${ROOT_DIR}/src/server/index.js`,
|
||||
server: `${ROOT_DIR}/src/server/index.ts`,
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
|
||||
|
@ -9,16 +9,19 @@ const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const ESLintPlugin = require('eslint-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 nodeExternals = require('webpack-node-externals');
|
||||
const PUBLIC_URL = process.env.PUBLIC_URL || '/';
|
||||
|
||||
const frontendConfig = {
|
||||
entry: {
|
||||
frontend: './src/frontend/index.tsx',
|
||||
frontend: `${ROOT_DIR}/src/frontend/index.tsx`,
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'build'),
|
||||
path: BUILD_DIR,
|
||||
filename: 'assets/app-[name]-[fullhash].js',
|
||||
publicPath: PUBLIC_URL,
|
||||
},
|
||||
@ -89,16 +92,16 @@ const frontendConfig = {
|
||||
new CopyPlugin({
|
||||
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 = {
|
||||
entry: {
|
||||
server: './src/server/index.js',
|
||||
server: './src/server/index.ts',
|
||||
},
|
||||
target: "node",
|
||||
externals: [nodeExternals()],
|
||||
@ -234,4 +237,4 @@ const serverConfig = {
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = [frontendConfig, serverConfig];
|
||||
module.exports = [frontendConfig, serverConfig];
|
||||
|
Loading…
Reference in New Issue
Block a user