Setting up devserver with https #1703
-
Hi, First of all.. I am new to razzle / react / webpack stuff. I decided to start with react so I am moving small website blazor -> react. I am using razzle for SSR. What is actually not working? I managed to get working scss plugin after upgrading to newer version. I can see in source code linking, however images nor css appears in build folder. Website code: Source code for body (Home.js):
Source code for app (App.js):
.babelrc
razzle.config.js
razzle version 3.4.5 |
Beta Was this translation helpful? Give feedback.
Replies: 17 comments
-
That is razzle 4 config, module is not a option in razzle config, the Object assigns are wrong |
Beta Was this translation helpful? Give feedback.
-
Eh.. its didnt work either without How it should be correctly? Can you give me lead? Thanks |
Beta Was this translation helpful? Give feedback.
-
https://codesandbox.io/s/razzle-examples-basic-forked-k0xjb?file=/razzle.config.js |
Beta Was this translation helpful? Give feedback.
-
based on your config if I dont use Object.assign then any advice? |
Beta Was this translation helpful? Give feedback.
-
config.entry.server |
Beta Was this translation helpful? Give feedback.
-
Compile is now success.. thanks however still not copied image assets nor css. Additionaly, HMR is broken. Maybe its really not config.entry.server?
|
Beta Was this translation helpful? Give feedback.
-
Need to see the config |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Running in wsl? Also you remove the hmr so.. |
Beta Was this translation helpful? Give feedback.
-
Razzle start does not output css in dev. Does the css in js in dev. You can turn it on in dev with razzle options. See the docs for valid options. I recommend not setting output publicpath and using CLIENT_PUBLIC_PATH as a .env variable with https://localhost:port/ instead Also note that https can cause cors issues between ports. I would reccomend trying to just get the basic with-scss example working first before fiddeling with https in dev, i spent a long time getting https working in dev so as a beginner, put a hold on https in dev |
Beta Was this translation helpful? Give feedback.
-
Also make sure razzle plugins and razzle are the same versions |
Beta Was this translation helpful? Give feedback.
-
@fivethreeo I have to use https due my asp.net core force https.. If I would use http then it would result into http(s) mistmatch. razze plugins / razzle are same versions. Not running in WSL (if u mean windows subsystem for linux) HMR: If I use code with publicpath: thanks for tip.. I removed publicPath code output css/images: I guess youre right.. after I used command however |
Beta Was this translation helpful? Give feedback.
-
const path = require('path');
const LoadableWebpackPlugin = require("@loadable/webpack-plugin");
module.exports = {
plugins: ["scss"],
modifyWebpackConfig: (opts) =>
{
const config = opts.webpackConfig;
const target = opts.env.target;
const dev = opts.env.dev;
if (dev)
{
if (target === 'node')
{
}
else if (target === 'web')
{
config.devServer.https = true;
config.devServer.pfx = process.env.RAZZLE_PFX;
config.devServer.pfxPassphrase = process.env.RAZZLE_PFX_PASSPHRASE;
}
}
else if (target === 'node')
config.externals = [];
if (target === "web")
{
const filename = path.resolve(__dirname, "build");
config.plugins.push(
new LoadableWebpackPlugin({
outputAsset: false,
writeToDisk: { filename },
})
);
}
return config;
}
}; |
Beta Was this translation helpful? Give feedback.
-
https://github.com/jaredpalmer/razzle/blob/master/examples/with-single-exposed-port/razzle.config.js |
Beta Was this translation helpful? Give feedback.
-
thanks. loadable-stats is now generated! Also if I run
|
Beta Was this translation helpful? Give feedback.
-
Target mus be the underlying express server for proxy. also you need to set devserver.public to 'localhost:443' |
Beta Was this translation helpful? Give feedback.
-
Then change CLIENT_PUBLIC_PATH to https://localhost/ |
Beta Was this translation helpful? Give feedback.
https://codesandbox.io/s/razzle-examples-basic-forked-k0xjb?file=/razzle.config.js
https://codesandbox.io/s/razzle-examples-basic-forked-k0xjb?file=/package.json