Skip to content

Commit

Permalink
Absorb the extracttextplugin
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Sep 9, 2016
1 parent 48a0896 commit ab3834d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
11 changes: 10 additions & 1 deletion jupyterlab/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
13 changes: 3 additions & 10 deletions jupyterlab/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,7 +32,7 @@ module.exports = [{
output: {
path: __dirname + '/build',
filename: '[name].bundle.js',
publicPath: './lab/'
publicPath: 'lab/'
},
node: {
fs: 'empty',
Expand All @@ -49,7 +44,6 @@ module.exports = [{
loaders: LOADERS
},
plugins: [
new ExtractTextPlugin('[name].css'),
new JupyterLabPlugin()
],
},
Expand Down Expand Up @@ -77,7 +71,7 @@ module.exports = [{
output: {
path: __dirname + '/build',
filename: '[name].bundle.js',
publicPath: './lab/'
publicPath: 'lab/'
},
node: {
fs: 'empty'
Expand All @@ -89,7 +83,6 @@ module.exports = [{
loaders: LOADERS
},
plugins: [
new ExtractTextPlugin('[name].css'),
new JupyterLabPlugin()
],
}
Expand Down

0 comments on commit ab3834d

Please sign in to comment.