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

#987 optimizing and compressing webpack assets #996

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions dashboard/templates/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
<div id="root"></div>
<!-- Webpack rendered JS -->
{% render_bundle 'main' 'js' %}
{% render_bundle 'vendors' 'js' %}
{% endblock %}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Add newline to end of file. I know it's not a change made for this PR, but it's an easy thing to catch and correct.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"webpack-cli": "~3.2.3",
"webpack-dev-server": "~3.2.1",
"webpack-manifest-plugin": "2.0.4",
"workbox-webpack-plugin": "4.1.0"
"workbox-webpack-plugin": "4.1.0",
"compression-webpack-plugin": "~4.0.0"
}
}
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if [ "${IS_CRON_POD:-"false",,}" == "false" ]; then
echo Starting Runserver for development
export PYTHONPATH="/code:$PYTHONPATH"
export DJANGO_SETTINGS_MODULE=dashboard.settings
exec django-admin runserver --ptvsd 0.0.0.0:${GUNICORN_PORT}
exec django-admin runserver --nostatic --ptvsd 0.0.0.0:${GUNICORN_PORT}
jonespm marked this conversation as resolved.
Show resolved Hide resolved

fi
else
Expand Down
28 changes: 27 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
const path = require('path')
const BundleTracker = require('webpack-bundle-tracker')
const CompressionPlugin = require('compression-webpack-plugin')

const isDevelopment = process.env.BABEL_ENV !== 'production'
module.exports = {
mode: isDevelopment ? 'development' : 'production',
entry: path.join(__dirname, 'assets/src/index'),
output: {
path: path.join(__dirname, 'assets/dist'),
filename: '[name]-[hash].js'
filename: '[name].[hash].js'
},
devtool: isDevelopment ? 'inline-source-map' : 'false',
watchOptions: {
ignored: /node_modules/,
aggregateTimeout: 600
},
module: {
rules: [
Expand All @@ -27,10 +35,28 @@ module.exports = {
}
]
},
optimization: {
splitChunks: {
cacheGroups: {
vendors: {
name: 'vendors',
test: /[\\/]node_modules[\\/]/,
chunks: 'all'
}
}
}
},
plugins: [
new BundleTracker({
path: __dirname,
filename: 'webpack-stats.json'
}),
new CompressionPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0.8
})
]
}