unistore 与 preact-cli 和 ssr
unistore with preact-cli and ssr
我将 unistore 与 preact-cli 一起使用,并且它与 --no-prerender 选项一起使用。现在我想对我的应用程序进行 SSR,但它需要转译,但我不知道如何只为我的 server.js 编写 webpack.config,而其他文件保持不变。
const MainAppContainer = require('../src/components/app')
const { Provider } = require('unistore/preact')
const createStore = require('../src/components/store')
const express = require('express');
const { h } = require('preact');
const path = require('path');
const store = createStore(initialState)
let state = store.getState()
let body = render(
<Provider store={store}>
<MainAppContainer url={req.url}/>
</Provider>
)
const AppHtml = template.replace(RGX, body);
目录结构
- 建造
- 源码
- 服务器
- 模板
- package.json
注意
project is created by preact-cli with the default template
so if i exclude server.js within server folder everything is compiled and run as mentioned in the preact-cli doc.
i just want a solution that how to compile server.js
every solution or sugesstion will be appreciated. thanks to all
您可以从 build/ssr-bundle.js
呈现您的应用程序。
我将 unistore 与 preact-cli 一起使用,并且它与 --no-prerender 选项一起使用。现在我想对我的应用程序进行 SSR,但它需要转译,但我不知道如何只为我的 server.js 编写 webpack.config,而其他文件保持不变。
const MainAppContainer = require('../src/components/app')
const { Provider } = require('unistore/preact')
const createStore = require('../src/components/store')
const express = require('express');
const { h } = require('preact');
const path = require('path');
const store = createStore(initialState)
let state = store.getState()
let body = render(
<Provider store={store}>
<MainAppContainer url={req.url}/>
</Provider>
)
const AppHtml = template.replace(RGX, body);
目录结构
- 建造
- 源码
- 服务器
- 模板
- package.json
注意
project is created by preact-cli with the default template so if i exclude server.js within server folder everything is compiled and run as mentioned in the preact-cli doc. i just want a solution that how to compile server.js every solution or sugesstion will be appreciated. thanks to all
您可以从 build/ssr-bundle.js
呈现您的应用程序。