1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-11 02:12:53 +00:00

fixing bundling - it's too big

This commit is contained in:
2016-10-17 20:42:32 +00:00
parent 090f580d23
commit 29778cadc1
4 changed files with 27 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
import hljs from 'highlight.js'; import hljs from 'hljs';
import marked from 'marked'; import marked from 'marked';
import React from 'react'; import React from 'react';
import {Link} from 'react-router'; import {Link} from 'react-router';

View File

@@ -7,6 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Mitchell Gerber"> <meta name="author" content="Mitchell Gerber">
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab:300,400" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto+Slab:300,400" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js"></script>
<title>mitchel.io</title> <title>mitchel.io</title>
</head> </head>

View File

@@ -4,13 +4,14 @@
"description": "My personal website built with React and Go", "description": "My personal website built with React and Go",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "webpack && babel-node metadata.js", "analyze": "webpack --json | webpack-bundle-size-analyzer",
"build": "NODE_ENV=production webpack -p --progress --colors && babel-node metadata.js",
"c9": "webpack-dev-server --port $PORT --host $IP --hot --content-base dist --history-api-fallback", "c9": "webpack-dev-server --port $PORT --host $IP --hot --content-base dist --history-api-fallback",
"check_gzip_size": "gzip -9 -c ./public/client.min.js | wc -c | numfmt --to=iec-i --suffix=B --padding=10", "check_gzip_size": "gzip -9 -c ./public/client.min.js | wc -c | numfmt --to=iec-i --suffix=B --padding=10",
"deploy": "npm run get_dependencies && npm run prod && ./mywebsite", "deploy": "npm run get_dependencies && npm run prod && ./mywebsite",
"dev": "webpack-dev-server --content-base public --inline --hot --history-api-fallback", "dev": "webpack-dev-server --content-base public --inline --hot --history-api-fallback",
"get_dependencies": "go get ./server && npm install", "get_dependencies": "go get ./server && npm install",
"prod": "NODE_ENV=production webpack -p --define process.env.NODE_ENV='\"production\"' --progress --colors && babel-node metadata.js && go build ./server/mywebsite.go", "prod": "npm run build && go build ./server/mywebsite.go",
"prod-win": "webpack -p --define process.env.NODE_ENV='\"production\"' --progress --colors && babel-node metadata.js && go build ./server/mywebsite.go", "prod-win": "webpack -p --define process.env.NODE_ENV='\"production\"' --progress --colors && babel-node metadata.js && go build ./server/mywebsite.go",
"watch": "webpack --watch --colors --progress" "watch": "webpack --watch --colors --progress"
}, },
@@ -42,7 +43,7 @@
"exports-loader": "^0.6.3", "exports-loader": "^0.6.3",
"file-loader": "^0.9.0", "file-loader": "^0.9.0",
"font-awesome": "^4.6.3", "font-awesome": "^4.6.3",
"highlight.js": "^9.6.0", "highlight.js": "^9.7.0",
"html-webpack-plugin": "^2.22.0", "html-webpack-plugin": "^2.22.0",
"marked": "^0.3.6", "marked": "^0.3.6",
"ncp": "^2.0.0", "ncp": "^2.0.0",

View File

@@ -6,7 +6,7 @@ var autoprefixer = require('autoprefixer');
module.exports = { module.exports = {
devtool: debug ? "inline-sourcemap" : null, devtool: debug ? "inline-sourcemap" : null,
entry: ["babel-polyfill", , "whatwg-fetch", "./client/js/app.js"], entry: ["babel-polyfill", "./client/js/app.js"],
module: { module: {
loaders: [ loaders: [
{ {
@@ -35,17 +35,27 @@ module.exports = {
publicPath: "/public/", publicPath: "/public/",
filename: "client.min.js" filename: "client.min.js"
}, },
plugins: debug ? [] : [ plugins: getPlugins(),
new webpack.optimize.DedupePlugin(), externals:{hljs: "hljs"}
new webpack.optimize.OccurenceOrderPlugin(), };
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
], function getPlugins(){
plugins: [ var plugins = [
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
fileName: 'index.html', fileName: 'index.html',
template: 'index.html', template: 'index.html',
inject: 'body', inject: 'body',
hash: true hash: true
}) }),
] new webpack.EnvironmentPlugin([
}; "NODE_ENV"
])
];
if(!debug){
plugins = plugins.concat([
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false})
])}
return plugins;
}