-
Notifications
You must be signed in to change notification settings - Fork 18
Enhance prod minification #38
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| }, | ||
| "scripts": { | ||
| "start": "better-npm-run dev:build && better-npm-run dev:start", | ||
| "prod": "better-npm-run prod:build && better-npm-run serve", | ||
| "serve": "better-npm-run serve", | ||
| "dev:start": "better-npm-run dev:start", | ||
| "dev:start:server": "better-npm-run dev:start:server", | ||
|
|
@@ -124,16 +125,19 @@ | |
| "redbox-react": "^1.5.0", | ||
| "supertest": "^3.0.0", | ||
| "webpack-dev-server": "^2.9.6", | ||
| "webpack-dev-server": "^2.9.7", | ||
| "webpack-sources": "^1.1.0" | ||
| }, | ||
| "dependencies": { | ||
| "app-module-path": "^2.2.0", | ||
| "autoprefixer": "^7.2.1", | ||
|
||
| "autoprefixer": "^7.2.2", | ||
| "axios": "^0.17.1", | ||
| "babel": "^6.23.0", | ||
| "babel-cli": "^6.26.0", | ||
| "babel-core": "^6.26.0", | ||
| "babel-loader": "^7.1.1", | ||
|
||
| "babel-loader": "^7.1.2", | ||
| "babel-plugin-react-transform": "^3.0.0", | ||
| "babel-plugin-resolver": "^1.1.0", | ||
| "babel-plugin-syntax-class-properties": "^6.13.0", | ||
|
|
@@ -171,6 +175,7 @@ | |
| "lodash": "^4.17.4", | ||
| "mocha": "^4.0.1", | ||
| "node-sass": "^4.7.2", | ||
| "postcss-csso": "^3.0.0", | ||
| "postcss-loader": "^2.0.9", | ||
| "react": "^16.2.0", | ||
| "react-dom": "^16.2.0", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| const autoprefixer = require('autoprefixer'); | ||
| const csso = require('postcss-csso')({restructure: true, comments: false}); | ||
|
||
|
|
||
| const pluginsList = [autoprefixer]; | ||
| if (process.env.NODE_ENV === 'production') { | ||
| pluginsList.push(csso); | ||
| } | ||
| module.exports = { | ||
| plugins: [autoprefixer] | ||
| }; | ||
| plugins: pluginsList | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ app.use(compression()); | |
|
|
||
| // Add middleware to serve up all static files | ||
| app.use('/dist', | ||
| express.static(path.join(__dirname, '../dist')), | ||
| express.static(path.join(__dirname, '../dist/public')), | ||
|
||
| express.static(path.join(__dirname, '../common/images')), | ||
| express.static(path.join(__dirname, '../common/fonts')) | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,39 @@ | ||
| import webpack from 'webpack'; | ||
| import baseConfig from './base'; | ||
| import CompressionPlugin from 'compression-webpack-plugin'; | ||
| import CleanWebpackPlugin from 'clean-webpack-plugin'; | ||
|
||
| import UglifyJSPlugin from 'uglifyjs-webpack-plugin'; | ||
| let pathsToClean = [ | ||
| 'dist', | ||
| ]; | ||
|
|
||
| // the clean options to use | ||
| let cleanOptions = { | ||
| root: '/var/www/react/', | ||
|
||
| verbose: true, | ||
| dry: false, | ||
| }; | ||
| const plugins = [ | ||
| new CleanWebpackPlugin(pathsToClean, cleanOptions), | ||
| new webpack.BannerPlugin({ | ||
| banner: 'hash:[hash], chunkhash:[chunkhash], name:[name], filebase:[filebase], query:[query], file:[file]', | ||
| }), | ||
| new webpack.optimize.CommonsChunkPlugin({ | ||
| name: 'vendor', | ||
| filename: '[name].[hash].js', | ||
| minChunks: module => /node_modules/.test(module.resource) | ||
| }), | ||
| new webpack.optimize.AggressiveMergingPlugin(), | ||
| new webpack.optimize.ModuleConcatenationPlugin(), | ||
| new webpack.optimize.UglifyJsPlugin({ | ||
| compress: { | ||
| screw_ie8: true, | ||
| warnings: false | ||
| new UglifyJSPlugin({ | ||
| uglifyOptions: { | ||
| compress: { | ||
| warnings: false | ||
| }, | ||
| mangle: true, | ||
| output: { | ||
| comments: false, | ||
| }, | ||
| } | ||
| }), | ||
| new CompressionPlugin({ | ||
|
|
||
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.
Can you remove this line?