Browse Source

Add JupyterLab CSS bundler

Sylvain Corlay 6 years ago
parent
commit
99c3375c3a

+ 4 - 0
.gitignore

@@ -2,16 +2,20 @@ MANIFEST
 build
 dist
 lib
+
 jupyterlab/static
 jupyterlab/schemas
 jupyterlab/themes
 jupyterlab/geckodriver
+
 dev_mode/schemas
 dev_mode/static
 dev_mode/themes
 dev_mode/workspaces
 dev_mode/stats.json
 
+packages/nbconvert-css/style/
+
 packages/theme-*/static
 node_modules
 .cache

+ 2 - 0
dev_mode/package.json

@@ -57,6 +57,7 @@
     "@jupyterlab/markdownviewer-extension": "^1.0.0-alpha.6",
     "@jupyterlab/mathjax2": "^1.0.0-alpha.6",
     "@jupyterlab/mathjax2-extension": "^1.0.0-alpha.6",
+    "@jupyterlab/nbconvert-css": "^0.1.0",
     "@jupyterlab/notebook": "^1.0.0-alpha.7",
     "@jupyterlab/notebook-extension": "^1.0.0-alpha.6",
     "@jupyterlab/observables": "^2.2.0-alpha.6",
@@ -282,6 +283,7 @@
       "@jupyterlab/markdownviewer-extension": "../packages/markdownviewer-extension",
       "@jupyterlab/mathjax2": "../packages/mathjax2",
       "@jupyterlab/mathjax2-extension": "../packages/mathjax2-extension",
+      "@jupyterlab/nbconvert-css": "../packages/nbconvert-css",
       "@jupyterlab/notebook": "../packages/notebook",
       "@jupyterlab/notebook-extension": "../packages/notebook-extension",
       "@jupyterlab/observables": "../packages/observables",

+ 1 - 0
packages/metapackage/package.json

@@ -75,6 +75,7 @@
     "@jupyterlab/markdownviewer-extension": "^1.0.0-alpha.6",
     "@jupyterlab/mathjax2": "^1.0.0-alpha.6",
     "@jupyterlab/mathjax2-extension": "^1.0.0-alpha.6",
+    "@jupyterlab/nbconvert-css": "^0.1.0",
     "@jupyterlab/notebook": "^1.0.0-alpha.7",
     "@jupyterlab/notebook-extension": "^1.0.0-alpha.6",
     "@jupyterlab/observables": "^2.2.0-alpha.6",

+ 3 - 0
packages/metapackage/tsconfig.json

@@ -141,6 +141,9 @@
     {
       "path": "../mathjax2-extension"
     },
+    {
+      "path": "../nbconvert-css"
+    },
     {
       "path": "../notebook"
     },

+ 60 - 0
packages/nbconvert-css/package.json

@@ -0,0 +1,60 @@
+{
+  "name": "@jupyterlab/nbconvert-css",
+  "version": "0.1.0",
+  "description": "CSS bundle for the JupyterLab nbconvert template",
+  "homepage": "https://github.com/jupyterlab/jupyterlab",
+  "bugs": {
+    "url": "https://github.com/jupyterlab/jupyterlab/issues"
+  },
+  "license": "BSD-3-Clause",
+  "author": "Project Jupyter",
+  "files": [
+    "lib/*.d.ts",
+    "lib/*.js.map",
+    "lib/*.js",
+    "style/*.css"
+  ],
+  "main": "lib/index.js",
+  "types": "lib/index.d.ts",
+  "directories": {
+    "lib": "lib/"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/jupyterlab/jupyterlab.git"
+  },
+  "scripts": {
+    "build": "tsc -b && webpack && rimraf style/index.js",
+    "clean": "rimraf lib/ & rimraf style/",
+    "prepare": "npm run build",
+    "watch": "tsc -b --watch"
+  },
+  "dependencies": {
+    "@jupyterlab/apputils": "^1.0.0-alpha.6",
+    "@jupyterlab/cells": "^1.0.0-alpha.7",
+    "@jupyterlab/codemirror": "^1.0.0-alpha.6",
+    "@jupyterlab/notebook": "^1.0.0-alpha.7",
+    "@jupyterlab/outputarea": "^1.0.0-alpha.6",
+    "@jupyterlab/rendermime": "^1.0.0-alpha.6"
+  },
+  "devDependencies": {
+    "@jupyterlab/apputils": "^1.0.0-alpha.6",
+    "@jupyterlab/cells": "^1.0.0-alpha.7",
+    "@jupyterlab/codemirror": "^1.0.0-alpha.6",
+    "@jupyterlab/notebook": "^1.0.0-alpha.7",
+    "@jupyterlab/outputarea": "^1.0.0-alpha.6",
+    "@jupyterlab/rendermime": "^1.0.0-alpha.6",
+    "css-loader": "~2.1.1",
+    "file-loader": "~3.0.1",
+    "mini-css-extract-plugin": "~0.6.0",
+    "null-loader": "^1.0.0",
+    "rimraf": "~2.6.2",
+    "typescript": "~3.4.3",
+    "url-loader": "~1.1.2",
+    "webpack": "~4.29.6",
+    "webpack-cli": "^3.3.0"
+  },
+  "publishConfig": {
+    "access": "public"
+  }
+}

+ 21 - 0
packages/nbconvert-css/src/index.ts

@@ -0,0 +1,21 @@
+/* @jupyterlab/cells */
+import '@jupyterlab/cells/style/collapser.css';
+import '@jupyterlab/cells/style/headerfooter.css';
+import '@jupyterlab/cells/style/inputarea.css';
+import '@jupyterlab/cells/style/widget.css';
+
+/* @jupyterlab/outputarea */
+import '@jupyterlab/outputarea/style/index.css';
+
+/* @jupyterlab/notebook */
+import '@jupyterlab/notebook/style/index.css';
+
+/* @jupyterlab/rendermime */
+import '@jupyterlab/rendermime/style/index.css';
+
+/* @jupyterlab/apputils */
+import '@jupyterlab/apputils/style/materialcolors.css';
+import '@jupyterlab/apputils/style/styling.css';
+
+/* @jupyterlab/codemirror */
+import '@jupyterlab/codemirror/style/index.css';

+ 28 - 0
packages/nbconvert-css/tsconfig.json

@@ -0,0 +1,28 @@
+{
+  "extends": "../../tsconfigbase",
+  "compilerOptions": {
+    "outDir": "lib",
+    "rootDir": "src"
+  },
+  "include": ["src/*"],
+  "references": [
+    {
+      "path": "../apputils"
+    },
+    {
+      "path": "../cells"
+    },
+    {
+      "path": "../codemirror"
+    },
+    {
+      "path": "../notebook"
+    },
+    {
+      "path": "../outputarea"
+    },
+    {
+      "path": "../rendermime"
+    }
+  ]
+}

+ 56 - 0
packages/nbconvert-css/webpack.config.js

@@ -0,0 +1,56 @@
+const MiniCssExtractPlugin = require('mini-css-extract-plugin');
+const path = require('path');
+
+module.exports = {
+  entry: './lib',
+  output: {
+    filename: 'index.js',
+    path: path.resolve(__dirname, 'style')
+  },
+  plugins: [
+    new MiniCssExtractPlugin({
+      filename: 'index.css'
+    })
+  ],
+  module: {
+    rules: [
+      {
+        test: /\.css$/,
+        use: [
+          {
+            loader: MiniCssExtractPlugin.loader,
+            options: {
+              hmr: process.env.NODE_ENV === 'development'
+            }
+          },
+          'css-loader'
+        ]
+      },
+      {
+        test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
+        use: 'url-loader'
+      },
+      /* Use null-loader to drop resources that are not used in the CSS */
+      {
+        test: /\.(jpg|png|gif)$/,
+        use: 'null-loader'
+      },
+      {
+        test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
+        use: 'null-loader'
+      },
+      {
+        test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
+        use: 'null-loader'
+      },
+      {
+        test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
+        use: 'null-loader'
+      },
+      {
+        test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
+        use: 'null-loader'
+      }
+    ]
+  }
+};

+ 8 - 0
yarn.lock

@@ -8257,6 +8257,14 @@ null-check@^1.0.0:
   version "1.0.0"
   resolved "https://registry.yarnpkg.com/null-check/-/null-check-1.0.0.tgz#977dffd7176012b9ec30d2a39db5cf72a0439edd"
 
+null-loader@^1.0.0:
+  version "1.0.0"
+  resolved "https://registry.yarnpkg.com/null-loader/-/null-loader-1.0.0.tgz#90e85798e50e9dd1d568495a44e74829dec26744"
+  integrity sha512-mYLDjDVTkjTlFoidxRhzO75rdcwfVXfw5G5zpj8sXnBkHtKJxMk4hTcRR4i5SOhDB6EvcQuYriy6IV23eq6uog==
+  dependencies:
+    loader-utils "^1.2.3"
+    schema-utils "^1.0.0"
+
 number-is-nan@^1.0.0:
   version "1.0.1"
   resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"