Skip to content

Commit

Permalink
Fixed that darn CSS extraction thingy
Browse files Browse the repository at this point in the history
  • Loading branch information
JobLeonard committed Oct 20, 2017
1 parent efb727c commit 9897a49
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 164 deletions.
29 changes: 20 additions & 9 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@ set -o errexit

# Build static assets

echo ""
if [ "${1:-dev}" == "dev" ]; then
echo "Bundling development build and inserting it into HTML template"
echo "================================================================"
echo " Bundling development build and inserting it into HTML template"
echo "================================================================"
echo ""
webpack --config='webpack.config.dev.js' --progress --profile --colors
elif [ "${1:-dev}" == "prod" ]; then
echo "Testing production. Minifying + bundling production build and inserting it into HTML template"
webpack --config='webpack.config.testprod.js' --progress --profile --colors
elif [ "${1:-dev}" == "deploy" ]; then
echo "Building for deployment. Minifying + bundling production build and inserting it into HTML template"
webpack --config='webpack.config.deploy.js' --progress --profile --colors
echo "=========================================================="
echo " Building for production. Minifying + bundling production"
echo " build and inserting it into HTML template"
echo "=========================================================="
echo ""
webpack --config='webpack.config.prod.js' --progress --profile --colors
else
echo "Incorrect flags passed"
exit 1
Expand All @@ -36,17 +41,23 @@ build_status=$?

if [ $build_status == 0 ]; then

echo "Building static assets."
# I haven't figured out how to both generate correct paths in the webpack HTML
# template, and have the resulting index.html be put in the right folders.
# Yes, this is an ugly hack around my incompetence, but it works - Job
mv ./python/loom_viewer/index.html ./python/loom_viewer/static/index.html

cd python
echo "Installing loom python package"
echo ""
echo "================================"
echo " Installing loom python package"
echo "================================"
echo ""
python setup.py install --force
cd ..
else
echo "Minification not finished properly, aborting build"
echo ""
echo ""
echo " Minification not finished properly, aborting build"
echo ""
exit $build_status
fi
File renamed without changes.
2 changes: 2 additions & 0 deletions client/components/heatmap/heatmap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import L from 'leaflet';
import 'leaflet/dist/leaflet.css';

import React, { Component } from 'react';
import PropTypes from 'prop-types';

Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion client/loom.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'react-virtualized-select/styles.css';
import 'rc-slider/assets/index.css';

// Modified for crisp zoom
import './css/leaflet_crisp.css';
// import './css/leaflet_crisp.css';
// Required for react-bootstrap
import './css/bootstrap.css';
import './css/bootstrap-theme.css';
Expand Down
15 changes: 12 additions & 3 deletions deploy
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
#! /bin/bash

./build deploy
echo ""
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "!! Don't forget to update _version.py before deploying !!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
./build prod
build_status=$?
if [ $build_status == 0 ]; then
cd python
echo "Don't forget to update _version.py before deploying!'"
echo "Submitting to PyPi"
echo ""
echo "============================================================"
echo " Submitting to PyPi"
echo " (Did you remember to update _version.py before deploying?)"
echo "============================================================"
echo ""
python setup.py sdist upload -r pypi
cd ..
echo ""
Expand Down
28 changes: 15 additions & 13 deletions webpack.config.dev.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

// webpack needs the trailing slash for output.publicPath
const PUBLIC_PATH = 'http://localhost:8003/';
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CssoWebpackPlugin = require('csso-webpack-plugin').default;

module.exports = {
entry: {
Expand All @@ -13,31 +12,32 @@ module.exports = {
path: path.join(__dirname, './python/loom_viewer'),
filename: '[name].[hash].js',
sourceMapFilename: '[name].[hash].map',
publicPath: PUBLIC_PATH,
},
module: {
loaders: [
rules: [
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
],
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader',
}),
},
{
test: /\.(png|jpg|gif)$/,
loader: 'file-loader',
options: {
publicPath: PUBLIC_PATH,
name: 'static/images/[name]-[hash].[ext]',
name: '[name]-[hash].[ext]',
outputPath: 'static/',
publicPath: '/',
},
},
{
test: /\.(svg|eot|ttf|woff|woff2)$/,
loader: 'file-loader',
options: {
publicPath: PUBLIC_PATH,
name: 'static/fonts/[name]-[hash].[ext]',
name: '[name]-[hash].[ext]',
outputPath: 'static/',
publicPath: '/',
},
},
{
Expand All @@ -53,6 +53,8 @@ module.exports = {
'process.env.NODE_ENV': JSON.stringify('debug'),
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new ExtractTextPlugin('/static/styles-[contenthash].css'),
new CssoWebpackPlugin(),
new HtmlWebpackPlugin({
template: path.join(__dirname + '/client/index.html'),
filename: 'index.html',
Expand Down
40 changes: 15 additions & 25 deletions webpack.config.deploy.js → webpack.config.prod.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const PUBLIC_PATH = 'http://loom.linnarssonlab.org/';
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CssoWebpackPlugin = require('csso-webpack-plugin').default;

const uglifySettings = {
mangle: {
Expand Down Expand Up @@ -50,42 +50,30 @@ module.exports = {
sourceMapFilename: '[name].[hash].map',
},
module: {
loaders: [
rules: [
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
options: {
publicPath: PUBLIC_PATH,
minimize: true,
sourceMap: false,
},
},
{
loader: 'css-loader',
options: {
publicPath: PUBLIC_PATH,
minimize: true,
sourceMap: false,
},
},
],
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader',
}),
},
{
test: /\.(png|jpg|gif)$/,
loader: 'file-loader',
options: {
publicPath: PUBLIC_PATH,
name: 'static/images/[name]-[hash].[ext]',
name: '[name]-[hash].[ext]',
outputPath: 'static/',
publicPath: '/',
},
},
{
test: /\.(svg|eot|ttf|woff|woff2)$/,
loader: 'file-loader',
options: {
publicPath: PUBLIC_PATH,
name: 'static/fonts/[name]-[hash].[ext]',
name: '[name]-[hash].[ext]',
outputPath: 'static/',
publicPath: '/',
},
},
{
Expand All @@ -102,6 +90,8 @@ module.exports = {
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.optimize.UglifyJsPlugin(uglifySettings),
new ExtractTextPlugin('/static/styles-[contenthash].css'),
new CssoWebpackPlugin(),
new HtmlWebpackPlugin({
template: path.join(__dirname + '/client/index.html'),
filename: 'index.html',
Expand Down
113 changes: 0 additions & 113 deletions webpack.config.testprod.js

This file was deleted.

0 comments on commit 9897a49

Please sign in to comment.