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

Support React on Rails by merging Webpacker Lite #601

Closed
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 9 additions & 2 deletions lib/install/config/webpack/development.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Note: You must restart bin/webpack-dev-server for changes to take effect

const webpack = require('webpack')
const merge = require('webpack-merge')
const sharedConfig = require('./shared.js')
const { settings, output } = require('./configuration.js')
const { settings, output, env } = require('./configuration.js')

module.exports = merge(sharedConfig, {
devtool: 'cheap-eval-source-map',
Expand All @@ -16,6 +17,7 @@ module.exports = merge(sharedConfig, {
https: settings.dev_server.https,
host: settings.dev_server.host,
port: settings.dev_server.port,
hot: settings.dev_server.hmr,
contentBase: output.path,
publicPath: output.publicPath,
compress: true,
Expand All @@ -27,5 +29,10 @@ module.exports = merge(sharedConfig, {
stats: {
errorDetails: true
}
}
},

plugins: settings.dev_server.hmr ? [
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin()
] : []
})
4 changes: 1 addition & 3 deletions lib/install/config/webpack/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ module.exports = {
plugins: [
new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))),
new ExtractTextPlugin(env.NODE_ENV === 'production' ? '[name]-[contenthash].css' : '[name].css'),
new ManifestPlugin({
writeToFileEmit: true
})
new ManifestPlugin({ writeToFileEmit: true })
],

resolve: {
Expand Down
2 changes: 1 addition & 1 deletion lib/install/config/webpacker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ development:
host: localhost
port: 8080
https: false
hot_reloading: false
hmr: false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gauravtiwari @dhh FWIW, the docs for devServer.hot use hot and not hmr.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think hmr is consistent with names like 'WEBPACKER_HMR'

Also, considering usages like Webpacker::DevServer.hmr? and def hmr?, they are consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ytbryan I agree in the sense that DevServer.hot? and WEBPACKER_HOT are a bit ambiguous.


test:
<<: *default
Expand Down