Skip to content

Commit

Permalink
Use assets manifest and udata 1.6 theme changes
Browse files Browse the repository at this point in the history
  • Loading branch information
noirbizarre committed Oct 15, 2018
1 parent c448f9e commit a1e73d8
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 10 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Expand Up @@ -24,6 +24,7 @@ jobs:
command: |
virtualenv venv
source venv/bin/activate
pip install -e . || pip install -e .
pip install -r requirements/develop.pip || pip install -r requirements/develop.pip
- save_cache:
key: py-cache-v3-{{ arch }}-{{ .Branch }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -99,3 +99,4 @@ ENV/
# assets
/node_modules
/gouvlu/theme/static/
/gouvlu/theme/manifest.json
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,8 @@

## Current (in progress)

- Nothing yet
- Use an assets manifest for improved caching [#102](https://github.com/opendatalu/gouvlu/pull/102)
- Expose theme assets for udata 1.6 [#102](https://github.com/opendatalu/gouvlu/pull/102)

## 1.1.1 (2018-09-11)

Expand Down
2 changes: 1 addition & 1 deletion gouvlu/theme/templates/oembed.html
@@ -1,5 +1,5 @@
{% extends 'oembed.html' %}

{% block extra_css %}
<link rel="stylesheet" href="{{ theme_static('oembed.css', external=True) }}" />
<link href="{{ manifest('theme', 'oembed.css', external=True) }}" rel="stylesheet">
{% endblock %}
5 changes: 5 additions & 0 deletions gouvlu/theme/templates/raw.html
Expand Up @@ -24,6 +24,11 @@
<meta name="theme-color" content="{{ current_theme.info.color }}">
{% endblock %}

{% block theme_css %}
{{ super() }}
<link href="{{ manifest('theme', 'theme.css') }}" rel="stylesheet">
{% endblock %}


{% block extra_js %}
{{ super() }}
Expand Down
37 changes: 37 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -27,7 +27,8 @@
"style-loader": "^0.21.0",
"uglifyjs-webpack-plugin": "^1.2.7",
"webpack": "^4.16.3",
"webpack-cli": "^3.1.0"
"webpack-cli": "^3.1.0",
"webpack-manifest-plugin": "^2.0.4"
},
"dependencies": {
"bootstrap": "^3.3.7",
Expand Down
2 changes: 1 addition & 1 deletion requirements/install.pip
@@ -1,3 +1,3 @@
udata>=1.5.3
udata>=1.6.0
feedparser
requests==2.19.1
22 changes: 16 additions & 6 deletions webpack.config.js
Expand Up @@ -4,8 +4,11 @@ const path = require('path');
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const ManifestPlugin = require('webpack-manifest-plugin');

const static_path = path.resolve('./gouvlu/theme/static');
const public_path = '/_themes/gouvlu/';
const theme_path = path.resolve('./gouvlu/theme');
const static_path = path.join(theme_path, 'static');
const source_path = path.resolve('./assets');

module.exports = function(env, argv) {
Expand All @@ -18,8 +21,9 @@ module.exports = function(env, argv) {
},
output: {
path: static_path,
publicPath: "/_themes/gouvlu/",
filename: "[name].js"
publicPath: public_path,
filename: "[name].[hash].js",
chunkFilename: 'chunks/[id].[hash].js'
},
resolve: {
modules: [
Expand All @@ -35,15 +39,21 @@ module.exports = function(env, argv) {
{loader: 'less-loader', options: {sourceMap: true}},
]},
{test: /img\/.*\.(jpg|jpeg|png|gif|svg)$/, loader: 'file-loader', options: {
name: '[path][name].[ext]?[hash]', context: source_path
name: '[path][name].[ext]', context: source_path
}},
]
},
devtool: isProd ? 'source-map' : 'eval',
plugins: [
new ManifestPlugin({
fileName: path.join(theme_path, 'manifest.json'),
// Filter out chunks and source maps
filter: ({name, isInitial, isChunk}) => !name.endsWith('.map') && (isInitial || !isChunk),
publicPath: public_path,
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
filename: '[name].[hash].css',
chunkFilename: '[id].[hash].css',
}),
]
};
Expand Down

0 comments on commit a1e73d8

Please sign in to comment.