-
Notifications
You must be signed in to change notification settings - Fork 564
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
Webpack4 migrate #958
Webpack4 migrate #958
Conversation
change webpack config: 1- replace ExtractTextPlugin with MiniCssExtractPlugin 2- required packages updates 3- add production public path 4- everything is working as expected 5- will migrate to react 16
…ls, css-loader and webpack-dev-middleware
@againksy this is great, and well needed, thanks for taking the time to send this PR! I will have a look in the comming days! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments, mostly cosmetic.
Seems like the application runs fine in prod, dev and test 👍
There are some warnings though:
Regarding styles
You are using @apply rule and custom property sets.
This feature won't be included in the next major release of postcss-cssnext.
Regarding code splitting / performance
WARNING in webpack performance recommendations:
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
For more info visit https://webpack.js.org/guides/code-splitting/
This might be an old warning though
Regarding lint
npm run lint
✖ 278 problems (278 errors, 0 warnings)
169 errors and 0 warnings potentially fixable with the--fix
option.
import MainSection from '../../components/MainSection'; | ||
import TopicItem from '../../components/TopicItem'; | ||
import Adapter from 'enzyme-adapter-react-16'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move above local imports
app/tests/setup.js
Outdated
@@ -1,13 +1,16 @@ | |||
require('babel-register') ({ | |||
presets: ['es2015', 'react', 'stage-0'] | |||
}); | |||
var jsdom = require('jsdom').jsdom; | |||
var jsdom = require('jsdom'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var
-> const
package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "react-webpack-node", | |||
"version": "3.4.1", | |||
"version": "4.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure when it makes sense to bump a major version for this kind of a package, any other oppinions on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GGAlanSmithee maybe 3.5.0 or some funny 3.4.4444 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GGAlanSmithee what you think? I ll set it
webpack/paths.js
Outdated
@@ -12,6 +12,7 @@ module.exports = { | |||
assets: path.resolve(CURRENT_WORKING_DIR, 'public', 'assets'), | |||
compiled: path.resolve(CURRENT_WORKING_DIR, 'compiled'), | |||
public: '/assets/', // use absolute path for css-loader? | |||
prod_public: '/', // use absolute path for css-loader? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does prod_public
do? Cannot find any documentation regarding this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GGAlanSmithee in prod with public: '/assets/'
the app tries to get the js and css from '/assets//assets/*' i did not searched why- just changed the prod publicPath for '/'.
I ll add comments about this.
webpack/plugins.js
Outdated
@@ -1,5 +1,5 @@ | |||
const webpack = require('webpack'); | |||
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |||
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"
-> '
webpack/plugins.js
Outdated
new ManifestPlugin({ | ||
fileName: 'manifest.json' | ||
}) | ||
]; | ||
} | ||
return []; | ||
}; | ||
// migration to webpack 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove these comments before merge
webpack/rules/css.js
Outdated
@@ -19,7 +19,7 @@ module.exports = ({ production = false, browser = false } = {}) => { | |||
* | |||
* Referenced from: https://github.com/webpack-contrib/css-loader#css-scope | |||
* | |||
* For prerendering with extract-text-webpack-plugin you should use | |||
* For prerendering with extract-text-webpack-plugin (replaced with mini-css-extract-plugin) you should use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normalize this comment, no need to mention old packages,
For prerendering with mini-css-extract-plugin ...
if we want to fix warning
|
server/db/mongo/constants.js
Outdated
@@ -1,4 +1,5 @@ | |||
export const db = process.env.MONGOHQ_URL || process.env.MONGODB_URI || 'mongodb://localhost/ReactWebpackNode'; | |||
// export const db = process.env.MONGOHQ_URL || process.env.MONGODB_URI || 'mongodb://localhost/ReactWebpackNode'; | |||
export const db = 'mongodb://reactgo_user_1:rgouser1pass@ds215093.mlab.com:15093/reactgo_sample'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert this ;)
webpack/paths.js
Outdated
@@ -12,7 +12,10 @@ module.exports = { | |||
assets: path.resolve(CURRENT_WORKING_DIR, 'public', 'assets'), | |||
compiled: path.resolve(CURRENT_WORKING_DIR, 'compiled'), | |||
public: '/assets/', // use absolute path for css-loader? | |||
prod_public: '/', // use absolute path for css-loader? | |||
prod_public: '/', // public path for production build should be like this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the additional info. I do have a feeling that this is actually a problem with the rendering and/or webpack asset serving in dev mode (hmr etc9 and not the output parameter, I will take a look.
Also, If we keep these, let's try to inline the comments, something like:
public: '/assets/',
prod_public: '/', // prod assets area already prefixed with '/assets/'
@againksy this is great - thanks a million! |
this is the migration to webpack 4 and react 16