Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ APPLICATION_BASE_URL=http://localhost:3000
ASSET_HOST=/dist

# The output path for webpack builds.
WEBPACK_OUTPUT_PATH=/dist
WEBPACK_OUTPUT_PATH=/dist/public

# Settings for webpack-dev-server.
DEV_SERVER_PORT=3001
DEV_SERVER_HOSTNAME=localhost
DEV_SERVER_HOST_URL=http://localhost:3001

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -124,16 +125,19 @@
"redbox-react": "^1.5.0",
"supertest": "^3.0.0",
"webpack-dev-server": "^2.9.6",
Copy link
Member

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?

"webpack-dev-server": "^2.9.7",
"webpack-sources": "^1.1.0"
},
"dependencies": {
"app-module-path": "^2.2.0",
"autoprefixer": "^7.2.1",
Copy link
Member

Choose a reason for hiding this comment

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

This line as well.

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

Choose a reason for hiding this comment

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

And this. :)

Please also commit package-lock.json

"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",
Expand Down Expand Up @@ -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",
Expand Down
9 changes: 7 additions & 2 deletions postcss.config.js
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});
Copy link
Member

Choose a reason for hiding this comment

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

style should have spacing between curly braces, e.g.
{restructure: true, comments: false}
to
{ restructure: true, comments: false }


const pluginsList = [autoprefixer];
if (process.env.NODE_ENV === 'production') {
pluginsList.push(csso);
}
module.exports = {
plugins: [autoprefixer]
};
plugins: pluginsList
}
2 changes: 1 addition & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
Copy link
Member

Choose a reason for hiding this comment

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

let's use process.env.WEBPACK_OUTPUT_PATH here instead.

express.static(path.join(__dirname, '../common/images')),
express.static(path.join(__dirname, '../common/fonts'))
);
Expand Down
4 changes: 1 addition & 3 deletions webpack/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ export default {
test: /\.css$/,
use: extractText.extract({
fallback: 'style-loader',
use: [
{ loader: 'css-loader' }
]
use: ['css-loader', 'postcss-loader'],
})
},
{
Expand Down
3 changes: 1 addition & 2 deletions webpack/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { mapValues, keyBy } from 'lodash';
*/
export const {
NODE_ENV, DEV_SERVER_PORT, DEV_SERVER_HOSTNAME, WEBPACK_OUTPUT_PATH,
ASSET_HOST, ASSET_PATH, ANALYZE, APPLICATION_BASE_URL
ASSET_HOST, ASSET_PATH, ANALYZE, APPLICATION_BASE_URL, DEV_SERVER_HOST_URL
} = process.env;

// The env vars to expose on the client side.
Expand All @@ -21,7 +21,6 @@ export const CLIENT_ENV_VARS = mapValues(
);

// The URL of the dev server including the hostname and port
export const DEV_SERVER_HOST_URL = `http://${DEV_SERVER_HOSTNAME}:${DEV_SERVER_PORT}`;

// The asset host to use for webpack files. In development, we will always use
// the dev server's URL.
Expand Down
3 changes: 2 additions & 1 deletion webpack/development.hot.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ new WebpackDevServer(webpack(config), {
version: false,
chunks: false,
children: false
}
},
disableHostCheck: true
}).listen(DEV_SERVER_PORT, DEV_SERVER_HOSTNAME, function errorCallback(err) {
if (err) {
console.error(err);
Expand Down
28 changes: 24 additions & 4 deletions webpack/production.babel.js
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';
Copy link
Member

@calvinl calvinl Dec 11, 2017

Choose a reason for hiding this comment

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

In production, this package is missing. Please add to package.json.

import UglifyJSPlugin from 'uglifyjs-webpack-plugin';
let pathsToClean = [
'dist',
];

// the clean options to use
let cleanOptions = {
root: '/var/www/react/',
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't __dirname be better here?

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({
Expand Down