Vendor hash support in prod config - Fixes #493 (#571)

* config: file styling

* config: update vendor files order

* config: webpack prod - add vendor hash support

* fix: remove submodule
This commit is contained in:
Dhruvdutt Jadhav 2018-02-27 01:20:13 +05:30 committed by Cassie Tarakajian
parent 287663494a
commit 4628b38be0
2 changed files with 47 additions and 47 deletions

View file

@ -1,4 +1,4 @@
var webpack = require('webpack'); const webpack = require('webpack');
require('dotenv').config(); require('dotenv').config();
module.exports = { module.exports = {
@ -14,7 +14,7 @@ module.exports = {
] ]
}, },
output: { output: {
path: __dirname + '/dist/', path: `${__dirname}/dist/`,
filename: 'app.js', filename: 'app.js',
publicPath: '/dist/' publicPath: '/dist/'
}, },
@ -34,15 +34,15 @@ module.exports = {
}), }),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'process.env': { 'process.env': {
API_URL: process.env.API_URL ? '"' + process.env.API_URL + '"' : undefined, API_URL: process.env.API_URL ? `"${process.env.API_URL}"` : undefined,
CLIENT: JSON.stringify(true), CLIENT: JSON.stringify(true),
FORCE_TO_HTTPS: process.env.FORCE_TO_HTTPS === 'true' ? FORCE_TO_HTTPS: process.env.FORCE_TO_HTTPS === 'true' ?
JSON.stringify(true) : JSON.stringify(true) :
JSON.stringify(false), JSON.stringify(false),
'NODE_ENV': JSON.stringify('development'), NODE_ENV: JSON.stringify('development'),
'S3_BUCKET': process.env.S3_BUCKET ? '"' + process.env.S3_BUCKET + '"' : undefined, S3_BUCKET: process.env.S3_BUCKET ? `"${process.env.S3_BUCKET}"` : undefined,
'S3_BUCKET_URL_BASE': process.env.S3_BUCKET_URL_BASE ? '"' + process.env.S3_BUCKET_URL_BASE + '"' : undefined, S3_BUCKET_URL_BASE: process.env.S3_BUCKET_URL_BASE ? `"${process.env.S3_BUCKET_URL_BASE}"` : undefined,
'AWS_REGION': process.env.AWS_REGION ? '"' + process.env.AWS_REGION + '"': undefined AWS_REGION: process.env.AWS_REGION ? `"${process.env.AWS_REGION}"` : undefined
} }
}) })
], ],

View file

@ -1,11 +1,11 @@
var webpack = require('webpack'); const webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin');
var ManifestPlugin = require('webpack-manifest-plugin'); const ManifestPlugin = require('webpack-manifest-plugin');
var ChunkManifestPlugin = require('chunk-manifest-webpack-plugin'); const ChunkManifestPlugin = require('chunk-manifest-webpack-plugin');
var cssnext = require('postcss-cssnext'); const cssnext = require('postcss-cssnext');
var postcssFocus = require('postcss-focus'); const postcssFocus = require('postcss-focus');
var postcssReporter = require('postcss-reporter'); const postcssReporter = require('postcss-reporter');
var cssnano = require('cssnano'); const cssnano = require('cssnano');
require('dotenv').config(); require('dotenv').config();
module.exports = { module.exports = {
@ -17,27 +17,27 @@ module.exports = {
'./client/index.jsx' './client/index.jsx'
], ],
vendor: [ vendor: [
'react',
'react-dom',
'redux',
'codemirror',
'moment',
'redux-form',
'react-redux',
'dropzone',
'axios', 'axios',
'classnames', 'classnames',
'react-inlinesvg', 'codemirror',
'react-router',
'redux-thunk',
'csslint', 'csslint',
'jshint', 'dropzone',
'htmlhint', 'htmlhint',
'js-beautify', 'js-beautify',
'jshint',
'moment',
'react-dom',
'react-inlinesvg',
'react-redux',
'react-router',
'react',
'redux-form',
'redux-thunk',
'redux',
] ]
}, },
output: { output: {
path: __dirname + '/static/dist', path: `${__dirname}/static/dist`,
filename: '[name].[chunkhash].js', filename: '[name].[chunkhash].js',
publicPath: '/dist/' publicPath: '/dist/'
}, },
@ -79,25 +79,25 @@ module.exports = {
plugins: [ plugins: [
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'process.env': { 'process.env': {
'API_URL': process.env.API_URL ? '"' + process.env.API_URL + '"' : undefined, API_URL: process.env.API_URL ? `"${process.env.API_URL}"` : undefined,
'NODE_ENV': JSON.stringify('production'), NODE_ENV: JSON.stringify('production'),
'S3_BUCKET': process.env.S3_BUCKET ? '"' + process.env.S3_BUCKET + '"' : undefined, S3_BUCKET: process.env.S3_BUCKET ? `"${process.env.S3_BUCKET}"` : undefined,
'S3_BUCKET_URL_BASE': process.env.S3_BUCKET_URL_BASE ? '"' + process.env.S3_BUCKET_URL_BASE + '"' : undefined, S3_BUCKET_URL_BASE: process.env.S3_BUCKET_URL_BASE ? `"${process.env.S3_BUCKET_URL_BASE}"` : undefined,
'AWS_REGION': process.env.AWS_REGION ? '"' + process.env.AWS_REGION + '"': undefined AWS_REGION: process.env.AWS_REGION ? `"${process.env.AWS_REGION}"` : undefined
} }
}), }),
new webpack.optimize.CommonsChunkPlugin({ new webpack.optimize.CommonsChunkPlugin({
name: 'vendor', name: 'vendor',
minChunks: Infinity, minChunks: Infinity,
filename: 'vendor.js', filename: '[name].[chunkhash].js',
}), }),
new ExtractTextPlugin({ filename: 'app.[chunkhash].css', allChunks: true }), new ExtractTextPlugin({ filename: 'app.[chunkhash].css', allChunks: true }),
new ManifestPlugin({ new ManifestPlugin({
basePath: '/', basePath: '/',
}), }),
new ChunkManifestPlugin({ new ChunkManifestPlugin({
filename: "chunk-manifest.json", filename: 'chunk-manifest.json',
manifestVariable: "webpackManifest", manifestVariable: 'webpackManifest',
}), }),
new webpack.optimize.UglifyJsPlugin({ new webpack.optimize.UglifyJsPlugin({
compress: { compress: {