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

Webpack4 migrate #958

Merged
merged 9 commits into from
Oct 12, 2018
Merged

Webpack4 migrate #958

merged 9 commits into from
Oct 12, 2018

Conversation

againksy
Copy link
Contributor

this is the migration to webpack 4 and react 16

z and others added 5 commits September 26, 2018 11:12
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
@GGAlanSmithee
Copy link
Member

@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! 🎉

Copy link
Member

@GGAlanSmithee GGAlanSmithee left a 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';
Copy link
Member

Choose a reason for hiding this comment

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

move above local imports

@@ -1,13 +1,16 @@
require('babel-register') ({
presets: ['es2015', 'react', 'stage-0']
});
var jsdom = require('jsdom').jsdom;
var jsdom = require('jsdom');
Copy link
Member

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",
Copy link
Member

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?

Copy link
Contributor Author

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 ?

Copy link
Contributor Author

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?
Copy link
Member

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.

Copy link
Contributor Author

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.

@@ -1,5 +1,5 @@
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
Copy link
Member

Choose a reason for hiding this comment

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

" -> '

new ManifestPlugin({
fileName: 'manifest.json'
})
];
}
return [];
};
// migration to webpack 4
Copy link
Member

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

@@ -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
Copy link
Member

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 ...

@againksy
Copy link
Contributor Author

if we want to fix warning

You are using @apply rule and custom property sets.
css @apply is abandoned : https://www.xanthir.com/b4o00 , http://tabatkins.github.io/specs/css-apply-rule/
we should migrate from @apply- maybe you or someone know some alternative- how to replace this @apply with something?

@@ -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';
Copy link
Member

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
Copy link
Member

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/'

@GGAlanSmithee
Copy link
Member

@againksy thanks for the update. Added a few more comments. Regarding @apply, I think we can leave this for now, and take it in a follow-up PR, since it's "only" a warning :)

@GGAlanSmithee GGAlanSmithee merged commit 1c97f65 into reactGo:master Oct 12, 2018
@GGAlanSmithee
Copy link
Member

@againksy this is great - thanks a million!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants