1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

Generate index.html using webpack

Allows webpack to generate the js and css tags rather than hard coding
them in
This commit is contained in:
Brett Sun 2016-06-02 15:26:28 +02:00
parent bd2895afa0
commit 1b52749f9d
3 changed files with 17 additions and 13 deletions

View File

@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
@ -10,16 +10,7 @@
<title>ascribe</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="<%= BASE_URL %>static/css/main.css">
<% DEBUG && print('<link rel="stylesheet" href="' + BASE_URL + 'static/css/maps/main.css.map">') %>
<script>
window.BASE_URL = '<%= BASE_URL %>';
window.SERVER_URL = '<%= SERVER_URL %>';
window.API_ENDPOINT = '<%= API_ENDPOINT %>';
<% DEBUG && print('window.DEBUG = true'); %>
<% DEBUG && print('window.CREDENTIALS = \'' + CREDENTIALS + '\''); %>
</script>
<!-- Typekit gibson font -->
<script src="https://use.typekit.net/gma2yhj.js"></script>
<script>
@ -44,8 +35,5 @@
s.src='https://widget.intercom.io/widget/{app_id}';
var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()
</script>
<!-- actual app -->
<script src="<%= BASE_URL %>static/js/app.js"></script>
</body>
</html>

View File

@ -84,6 +84,7 @@
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.5",
"history": "1.17.0",
"html-webpack-plugin": "^2.19.0",
"invariant": "^2.1.1",
"isomorphic-fetch": "^2.0.2",
"moment": "^2.10.6",

View File

@ -8,6 +8,7 @@ const webpack = require('webpack');
const autoPrefixer = require('autoprefixer');
const combineLoaders = require('webpack-combine-loaders');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
require('dotenv').load({ silent: true });
@ -38,6 +39,20 @@ const PLUGINS = [
allChunks: true
}
),
// Generate index.html for app with link and style tags addded
new HtmlWebpackPlugin({
filename: 'index.html',
minify: PRODUCTION ? {
collapseWhitespace: true,
minifyJS: true,
removeComments: true,
removeRedundantAttributes: true
} : false,
template: path.resolve(__dirname, 'index_template.html'),
}),
];
const PROD_PLUGINS = [
new webpack.optimize.UglifyJsPlugin({
compress: {