diff --git a/superset/__init__.py b/superset/__init__.py
index b8fccd9934f1..957645880433 100644
--- a/superset/__init__.py
+++ b/superset/__init__.py
@@ -32,19 +32,21 @@
app.config.from_object(CONFIG_MODULE)
conf = app.config
+# Handling manifest file logic at app start
+MANIFEST_FILE = APP_DIR + '/static/assets/dist/manifest.json'
+get_manifest_file = lambda x: x
+manifest = {}
+try:
+ with open(MANIFEST_FILE, 'r') as f:
+ manifest = json.load(f)
+ get_manifest_file = lambda x: '/static/assets/dist/' + manifest.get(x, '')
+except Exception:
+ print("no manifest file found at " + MANIFEST_FILE)
+
@app.context_processor
def get_js_manifest():
- manifest = {}
- try:
- with open(APP_DIR + '/static/assets/dist/manifest.json', 'r') as f:
- manifest = json.load(f)
- except Exception as e:
- print(
- "no manifest file found at " +
- APP_DIR + "/static/assets/dist/manifest.json"
- )
- return dict(js_manifest=manifest)
+ return dict(js_manifest=get_manifest_file)
for bp in conf.get('BLUEPRINTS'):
diff --git a/superset/assets/javascripts/SqlLab/index.jsx b/superset/assets/javascripts/SqlLab/index.jsx
index ba0992472017..4e2eae898c6d 100644
--- a/superset/assets/javascripts/SqlLab/index.jsx
+++ b/superset/assets/javascripts/SqlLab/index.jsx
@@ -10,7 +10,7 @@ import { initJQueryAjax } from '../modules/utils';
import App from './components/App';
import { appSetup } from '../common';
-import './main.css';
+import './main.less';
import '../../stylesheets/reactable-pagination.css';
import '../components/FilterableTable/FilterableTableStyles.css';
diff --git a/superset/assets/javascripts/SqlLab/main.css b/superset/assets/javascripts/SqlLab/main.less
similarity index 99%
rename from superset/assets/javascripts/SqlLab/main.css
rename to superset/assets/javascripts/SqlLab/main.less
index ad2bb37c0e3e..d5dab4c03cc0 100644
--- a/superset/assets/javascripts/SqlLab/main.css
+++ b/superset/assets/javascripts/SqlLab/main.less
@@ -161,7 +161,6 @@ div.Workspace {
margin: 0px;
border: none;
font-size: 12px;
- line-height: @line-height-base;
background-color: transparent !important;
}
diff --git a/superset/assets/javascripts/explore/index.jsx b/superset/assets/javascripts/explore/index.jsx
index 0fe4fcaba952..8d29d9eaf0da 100644
--- a/superset/assets/javascripts/explore/index.jsx
+++ b/superset/assets/javascripts/explore/index.jsx
@@ -19,7 +19,7 @@ import '../../stylesheets/reactable-pagination.css';
appSetup();
initJQueryAjax();
-const exploreViewContainer = document.getElementById('js-explore-view-container');
+const exploreViewContainer = document.getElementById('app');
const bootstrapData = JSON.parse(exploreViewContainer.getAttribute('data-bootstrap'));
const controls = getControlsState(bootstrapData, bootstrapData.form_data);
delete bootstrapData.form_data;
diff --git a/superset/assets/javascripts/css-theme.js b/superset/assets/javascripts/theme.js
similarity index 70%
rename from superset/assets/javascripts/css-theme.js
rename to superset/assets/javascripts/theme.js
index 8fab234f65f6..68a7a8ac5f02 100644
--- a/superset/assets/javascripts/css-theme.js
+++ b/superset/assets/javascripts/theme.js
@@ -1,2 +1,3 @@
import '../stylesheets/less/index.less';
import '../stylesheets/react-select/select.less';
+import '../stylesheets/superset.less';
diff --git a/superset/assets/package.json b/superset/assets/package.json
index 1422492bfea5..2dde6b337a95 100644
--- a/superset/assets/package.json
+++ b/superset/assets/package.json
@@ -108,6 +108,7 @@
"eslint-plugin-jsx-a11y": "^5.0.3",
"eslint-plugin-react": "^7.0.1",
"exports-loader": "^0.6.3",
+ "extract-text-webpack-plugin": "2.1.2",
"file-loader": "^0.11.1",
"github-changes": "^1.0.4",
"ignore-styles": "^5.0.1",
diff --git a/superset/assets/stylesheets/superset.css b/superset/assets/stylesheets/superset.less
similarity index 100%
rename from superset/assets/stylesheets/superset.css
rename to superset/assets/stylesheets/superset.less
diff --git a/superset/assets/webpack.config.js b/superset/assets/webpack.config.js
index e3413e5d14c2..10e41c96bd8f 100644
--- a/superset/assets/webpack.config.js
+++ b/superset/assets/webpack.config.js
@@ -2,6 +2,7 @@ const webpack = require('webpack');
const path = require('path');
const ManifestPlugin = require('webpack-manifest-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
+const ExtractTextPlugin = require('extract-text-webpack-plugin');
// input dir
const APP_DIR = path.resolve(__dirname, './');
@@ -14,7 +15,7 @@ const config = {
fs: 'empty',
},
entry: {
- 'css-theme': APP_DIR + '/javascripts/css-theme.js',
+ theme: APP_DIR + '/javascripts/theme.js',
common: APP_DIR + '/javascripts/common.js',
addSlice: ['babel-polyfill', APP_DIR + '/javascripts/addSlice/index.jsx'],
dashboard: ['babel-polyfill', APP_DIR + '/javascripts/dashboard/Dashboard.jsx'],
@@ -64,11 +65,24 @@ const config = {
include: APP_DIR + '/node_modules/mapbox-gl/js',
loader: 'babel-loader',
},
- /* for require('*.css') */
+ // Extract css files
{
test: /\.css$/,
include: APP_DIR,
- loader: 'style-loader!css-loader',
+ loader: ExtractTextPlugin.extract({
+ use: ['css-loader'],
+ fallback: 'style-loader',
+ }),
+ },
+ // Optionally extract less files
+ // or any other compile-to-css language
+ {
+ test: /\.less$/,
+ include: APP_DIR,
+ loader: ExtractTextPlugin.extract({
+ use: ['css-loader', 'less-loader'],
+ fallback: 'style-loader',
+ }),
},
/* for css linking images */
{
@@ -92,12 +106,6 @@ const config = {
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader',
},
- /* for require('*.less') */
- {
- test: /\.less$/,
- include: APP_DIR,
- loader: 'style-loader!css-loader!less-loader',
- },
/* for mapbox */
{
test: /\.json$/,
@@ -123,6 +131,7 @@ const config = {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
},
}),
+ new ExtractTextPlugin('[name].[chunkhash].css'),
],
};
if (process.env.NODE_ENV === 'production') {
diff --git a/superset/templates/superset/base.html b/superset/templates/superset/base.html
index 1a9c42cd89ca..b47104957a80 100644
--- a/superset/templates/superset/base.html
+++ b/superset/templates/superset/base.html
@@ -1,21 +1,12 @@
{% extends "appbuilder/baselayout.html" %}
{% block head_css %}
-
-
{{super()}}
- {% endblock %}
-
- {% block head_js %}
- {{super()}}
- {% with filename="css-theme" %}
- {% include "superset/partials/_script_tag.html" %}
- {% endwith %}
+
+
{% endblock %}
{% block tail_js %}
{{super()}}
- {% with filename="common" %}
- {% include "superset/partials/_script_tag.html" %}
- {% endwith %}
+
{% endblock %}
diff --git a/superset/templates/superset/basic.html b/superset/templates/superset/basic.html
index d4f2e1f55776..87b058d13eff 100644
--- a/superset/templates/superset/basic.html
+++ b/superset/templates/superset/basic.html
@@ -12,15 +12,16 @@
{% block head_meta %}{% endblock %}
{% block head_css %}
-
-
-
+
+
+
+ {% if entry %}
+
+ {% endif %}
{% endblock %}
{% block head_js %}
- {% with filename="css-theme" %}
- {% include "superset/partials/_script_tag.html" %}
- {% endwith %}
+
{% endblock %}
{% block tail_js %}
+ {% if entry %}
+
+ {% endif %}
{% endblock %}