Website content is not changed.
See original GitHub issueI’m having troubles to get it working with my webpack configuration. I’m sure that it’s a webpack issue. I’ve tried multiple configurations and webpack flags but nothing is working. Any idea? My webpack configuration is quite complex.
I’m starting the webpack-dev-server by webpack-dev-server --hot
command
/* eslint-disable no-console */
const webpack = require("webpack");
const path = require("path");
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const platform = "main";
const appVersion = "dev";
module.exports = {
mode: "development",
output: {
path: path.join(__dirname, "public/js"),
//filename: 'index.js',
publicPath: "/js/",
chunkFilename: `${platform}-[name]-${appVersion}.bundle.js`,
},
devServer: {
contentBase: "public/",
historyApiFallback: true,
disableHostCheck: true,
publicPath: "/js/",
hot: true,
},
entry: { main: `./src/app-${platform}.js` },
module: {
rules: [
{
test: /\.(js|jsx)$/,
// exclude: /(node_modules|bower_components)/,
include: [path.join(__dirname, "src")],
use: [
{
loader: "babel-loader",
options: {
compact: true,
presets: [
[
"@babel/preset-env",
{
targets: {
browsers: ["last 2 versions", "ie >= 11"],
},
spec: true,
debug: false,
shippedProposals: true,
},
],
"@babel/preset-react",
],
plugins: [
// Stage 0
"@babel/plugin-proposal-function-bind",
// Stage 1
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-logical-assignment-operators",
["@babel/plugin-proposal-optional-chaining", { loose: false }],
[
"@babel/plugin-proposal-pipeline-operator",
{ proposal: "minimal" },
],
[
"@babel/plugin-proposal-nullish-coalescing-operator",
{ loose: false },
],
"@babel/plugin-proposal-do-expressions",
// Stage 2
["@babel/plugin-proposal-decorators", { legacy: true }],
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-throw-expressions",
["@babel/plugin-proposal-class-properties", { loose: false }],
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-transform-object-assign",
"@babel/plugin-transform-for-of",
"@babel/plugin-transform-instanceof",
"@babel/plugin-transform-classes",
"@babel/plugin-transform-computed-properties",
"@babel/plugin-transform-destructuring",
"@babel/plugin-transform-function-name",
"@babel/plugin-transform-object-super",
"@babel/plugin-transform-parameters",
"@babel/plugin-transform-shorthand-properties",
"@babel/plugin-transform-spread",
"@babel/plugin-transform-sticky-regex",
"@babel/plugin-transform-template-literals",
"@babel/plugin-transform-unicode-regex",
"@babel/plugin-proposal-optional-catch-binding",
"babel-plugin-transform-merge-sibling-variables",
"babel-plugin-transform-inline-consecutive-adds",
"babel-plugin-transform-minify-booleans",
"babel-plugin-transform-property-literals",
require.resolve("react-refresh/babel"),
],
},
},
],
},
{
test: /\.[ac]ss$/i,
use: ["style-loader", "css-loader", "sass-loader"],
},
{
test: /\.(png|jp(e*)g|gif|svg)$/,
use: [
{
loader: "url-loader",
options: {
limit: 8192,
},
},
],
},
{
test: /\.md$/,
use: [
{
loader: "raw-loader",
},
],
},
],
},
resolve: {
extensions: [".js", ".jsx"],
alias: {
moment: "window.moment",
jQuery: "window.jQuery",
jquery: "window.jQuery",
"aws-amplify": 'window["aws-amplify"]',
firebase: 'window["firebase"]',
},
},
externals: [
{
moment: "moment",
jQuery: "jQuery",
jquery: "jQuery",
"aws-amplify": 'window["aws-amplify"]',
firebase: 'window["firebase"]',
},
],
plugins: [
new webpack.ProvidePlugin({
// inject ES5 modules as global vars
$: "jQuery",
jQuery: "jQuery",
"window.jQuery": "jQuery",
jquery: "jQuery",
"window.jquery": "jQuery",
// In case you imported plugins individually, we must also require them here:
Alert: "exports-loader?Alert!bootstrap/js/src/alert",
Button: "exports-loader?Button!bootstrap/js/src/button",
Carousel: "exports-loader?Carousel!bootstrap/js/src/carousel",
Dropdown: "exports-loader?Dropdown!bootstrap/js/src/dropdown",
Modal: "exports-loader?Modal!bootstrap/js/src/modal",
Popover: "exports-loader?Popover!bootstrap/js/src/popover",
ScrollSpy: "exports-loader?ScrollSpy!bootstrap/js/src/scrollspy",
Tab: "exports-loader?Tab!bootstrap/js/src/tab",
Tooltip: "exports-loader?Tooltip!bootstrap/js/src/tooltip",
Util: "exports-loader?Util!bootstrap/js/src/util",
moment: "moment",
"window.moment": "moment",
"aws-amplify": "aws-amplify",
'window["aws-amplify"]': "aws-amplify",
'window["firebase"]': "firebase",
}),
new webpack.DefinePlugin({
"process.env.SITE_NAME": JSON.stringify("example"),
}),
new webpack.HotModuleReplacementPlugin(),
new ReactRefreshWebpackPlugin(),
new HtmlWebpackPlugin({
template: "index.ejs",
templateParameters: {
...
},
}),
],
};
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
My Changes Don't Show Up on My Website - InMotion Hosting
Learn why a website change doesn't appear because of caching or other causes.
Read more >Can't See Changes You've Made to Your Website? Try ...
Luckily, that's a simple process. Click here for detailed instructions on how to clear your cache; just find the browser you're using and...
Read more >WordPress Changes Not Showing? Here's How to Fix ... - Kinsta
Having issues with WordPress changes not showing on your site? It's usually problems with caching - we'll show you how to fix the...
Read more >How to Fix WordPress Website Not Updating Right Away
Step 1. Force Browser to Reload or Clear Cache. Sometimes your browser (specially Google Chrome) will show you a cached copy of your...
Read more >Website builder: Why don't the changes I've made show on my ...
There may be several reasons why your changes are not visible online: The website hasn't been updated properly. You're having browser/network/DNS cache ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks a lot for your response! 😃 Really helped and I see that you have really deep understanding of webpack.
Happy that stuff worked for you - that’s one complex Webpack config.
The below are some of my thoughts on what might have impacted the behaviour:
This should only be related to caching and would not have impacted HMR.
This option only affects static files, so it is not likely it fixed the issue - however it is always recommended to use an absolute path (since it is more deterministic for Webpack).
This is pure security - enabling host check helps prevent DNS rebinding attacks.
Kinda same as (2) - this seems like you have some files that have to be copied over to initialize the app?
This definitely might have an impact since it alters the directory structure of how JS files are served from the generated HTML file. For instance, it might have been
localhost:3000/js/index.html
andlocalhost:3000/js/app.js
but then HMR files are routed into/
or any subdirectories withinjs
, yielding a failed HMR update. You can debug the behaviour by settingwriteToDisk: true
indevServer
.In addition to these changes, you might also want to remove
webpack.HotModuleReplacementPlugin
since you already usehot: true
and that tells WDS to inject the plugin for you (if not found).