Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(dev): fix shakpacker config for the webpack-dev-server #2280

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions config/shakapacker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ development:
dev_server:
# For running dev server with https, set `server: https`.
# server: https

host: <%= ENV['SHAPACKER_DEV_SERVER_HOST'] || 'localhost' %>
port: <%= ENV['SHAPACKER_DEV_SERVER_PORT'] || 3035 %>
## ERB does not seem to work
# host: <%= ENV['SHAPACKER_DEV_SERVER_HOST'] || 'localhost' %>
host: localhost
port: 3035
# Hot Module Replacement updates modules while the application is running without a full reload
# Used instead of the `hot` key in https://webpack.js.org/configuration/dev-server/#devserverhot
hmr: true
Expand All @@ -85,10 +86,10 @@ development:
# Should we show a full-screen overlay in the browser when there are compiler errors or warnings?
overlay: true
# May also be a string
webSocketURL:
hostname: 'localhost'
pathname: '/ws'
port: 3035
webSocketURL: 'ws://localhost:3035/ws'
# hostname: 'localhost'
# pathname: '/ws'
# port: 3035
# Should we use gzip compression?
compress: true
# Note that apps that do not check the host are vulnerable to DNS rebinding attacks
Expand Down
13 changes: 10 additions & 3 deletions config/webpack/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@ const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin'
const { merge } = require('shakapacker');
const webpackConfig = require('./base');
const developmentConfig = {
devServer: {
/*
devServer: {
port: '3035',
host: '0.0.0.0',
host: 'localhost',
compress: true,
hot: true,
allowedHosts: 'all',
headers: {
'Access-Control-Allow-Origin': '*',
}
},
*/
target: 'web',
plugins: [
new ReactRefreshWebpackPlugin()
],
watchOptions: {
ignored: /node_modules/, // Ignore node_modules directory
poll: 1000, // Optional: Use polling with a delay of 1 second
},
module: {
rules: [
{
Expand All @@ -37,4 +44,4 @@ const developmentConfig = {
}
};

module.exports = merge(webpackConfig, developmentConfig)
module.exports = merge(webpackConfig, developmentConfig);
Loading