From ab3834d157f61ad71c0dc81ed39ff7e5cbc34acf Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 7 Sep 2016 05:41:25 -0500 Subject: [PATCH] Absorb the extracttextplugin --- jupyterlab/plugin.js | 11 ++++++++++- jupyterlab/webpack.config.js | 13 +++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/jupyterlab/plugin.js b/jupyterlab/plugin.js index bbbce0cb707d..fefcf3a74c7c 100644 --- a/jupyterlab/plugin.js +++ b/jupyterlab/plugin.js @@ -2,7 +2,7 @@ // Distributed under the terms of the Modified BSD License. var path = require('path'); - +var ExtractTextPlugin = require('extract-text-webpack-plugin'); /** * A WebPack plugin that generates custom bundles that use version and @@ -14,12 +14,21 @@ function JupyterLabPlugin(options) { } +/** + * The css loader that should be used with the plugin. + */ +JupyterLabPlugin.cssLoader = ExtractTextPlugin.extract("style-loader", "css-loader", { publicPath: './' }); + + /** * Plugin installation, called by WebPack. * * @param compiler - The WebPack compiler object. */ JupyterLabPlugin.prototype.apply = function(compiler) { + // Run the extract text plugin. + compiler.apply(new ExtractTextPlugin('[name].css')); + var pluginName = this.name; var publicPath = compiler.options.output.publicPath; if (!publicPath) { diff --git a/jupyterlab/webpack.config.js b/jupyterlab/webpack.config.js index e178966b2636..1ffd76b4fead 100644 --- a/jupyterlab/webpack.config.js +++ b/jupyterlab/webpack.config.js @@ -5,18 +5,13 @@ // See https://github.com/webpack/css-loader/issues/144 require('es6-promise').polyfill(); -var ExtractTextPlugin = require('extract-text-webpack-plugin'); var JupyterLabPlugin = require('./plugin'); console.log('Generating bundles...'); var LOADERS = [ - { test: /\.css$/, - loader: ExtractTextPlugin.extract("style-loader", "css-loader", { - publicPath: './' - }) - }, + { test: /\.css$/, loader: JupyterLabPlugin.cssLoader }, { test: /\.json$/, loader: 'json-loader' }, { test: /\.html$/, loader: 'file-loader' }, // jquery-ui loads some images @@ -37,7 +32,7 @@ module.exports = [{ output: { path: __dirname + '/build', filename: '[name].bundle.js', - publicPath: './lab/' + publicPath: 'lab/' }, node: { fs: 'empty', @@ -49,7 +44,6 @@ module.exports = [{ loaders: LOADERS }, plugins: [ - new ExtractTextPlugin('[name].css'), new JupyterLabPlugin() ], }, @@ -77,7 +71,7 @@ module.exports = [{ output: { path: __dirname + '/build', filename: '[name].bundle.js', - publicPath: './lab/' + publicPath: 'lab/' }, node: { fs: 'empty' @@ -89,7 +83,6 @@ module.exports = [{ loaders: LOADERS }, plugins: [ - new ExtractTextPlugin('[name].css'), new JupyterLabPlugin() ], }