mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-31 09:57:03 +02:00
chore(v2): use null-loader for non css module in server bundle (#1388)
* chore(v2): use null-loader for non css module in server bundle * take out nprogress.css * css nits
This commit is contained in:
parent
6d53264652
commit
cfbece5488
5 changed files with 103 additions and 10 deletions
|
@ -8,8 +8,8 @@
|
|||
import React from 'react';
|
||||
import {Route, withRouter} from 'react-router-dom';
|
||||
import nprogress from 'nprogress';
|
||||
import 'nprogress/nprogress.css';
|
||||
import preload from './preload';
|
||||
import './nprogress.css';
|
||||
|
||||
nprogress.configure({showSpinner: false});
|
||||
|
||||
|
|
75
packages/docusaurus/lib/client/nprogress.css
Normal file
75
packages/docusaurus/lib/client/nprogress.css
Normal file
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
/* Make clicks pass-through */
|
||||
#nprogress {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
#nprogress .bar {
|
||||
background: #29d;
|
||||
position: fixed;
|
||||
z-index: 1031;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 2px;
|
||||
}
|
||||
|
||||
/* Fancy blur effect */
|
||||
#nprogress .peg {
|
||||
display: block;
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
width: 100px;
|
||||
height: 100%;
|
||||
box-shadow: 0 0 10px #29d, 0 0 5px #29d;
|
||||
opacity: 1.0;
|
||||
-webkit-transform: rotate(3deg) translate(0px, -4px);
|
||||
-ms-transform: rotate(3deg) translate(0px, -4px);
|
||||
transform: rotate(3deg) translate(0px, -4px);
|
||||
}
|
||||
|
||||
/* Remove these to get rid of the spinner */
|
||||
#nprogress .spinner {
|
||||
display: block;
|
||||
position: fixed;
|
||||
z-index: 1031;
|
||||
top: 15px;
|
||||
right: 15px;
|
||||
}
|
||||
|
||||
#nprogress .spinner-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
box-sizing: border-box;
|
||||
border: solid 2px transparent;
|
||||
border-top-color: #29d;
|
||||
border-left-color: #29d;
|
||||
border-radius: 50%;
|
||||
-webkit-animation: nprogress-spinner 400ms linear infinite;
|
||||
animation: nprogress-spinner 400ms linear infinite;
|
||||
}
|
||||
|
||||
.nprogress-custom-parent {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.nprogress-custom-parent #nprogress .spinner,
|
||||
.nprogress-custom-parent #nprogress .bar {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
@-webkit-keyframes nprogress-spinner {
|
||||
0% { -webkit-transform: rotate(0deg); }
|
||||
100% { -webkit-transform: rotate(360deg); }
|
||||
}
|
||||
@keyframes nprogress-spinner {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
|
@ -10,18 +10,27 @@ const cacheLoaderVersion = require('cache-loader/package.json').version;
|
|||
const merge = require('webpack-merge');
|
||||
|
||||
// Utility method to get style loaders
|
||||
function getStyleLoaders(isServer, cssOptions) {
|
||||
function getStyleLoaders(isServer, cssOptions = {}) {
|
||||
if (isServer) {
|
||||
// https://github.com/webpack-contrib/mini-css-extract-plugin/issues/90#issuecomment-380796867
|
||||
return [
|
||||
cssOptions.modules
|
||||
? {
|
||||
loader: require.resolve('css-loader/locals'),
|
||||
options: cssOptions,
|
||||
}
|
||||
: require.resolve('null-loader'),
|
||||
];
|
||||
}
|
||||
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
const loaders = [
|
||||
!isServer &&
|
||||
isProd && {
|
||||
loader: MiniCssExtractPlugin.loader,
|
||||
},
|
||||
!isServer && !isProd && require.resolve('style-loader'),
|
||||
isProd && {
|
||||
loader: MiniCssExtractPlugin.loader,
|
||||
},
|
||||
!isProd && require.resolve('style-loader'),
|
||||
{
|
||||
loader: isServer
|
||||
? require.resolve('css-loader/locals')
|
||||
: require.resolve('css-loader'),
|
||||
loader: require.resolve('css-loader'),
|
||||
options: cssOptions,
|
||||
},
|
||||
].filter(Boolean);
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
"lodash": "^4.17.11",
|
||||
"mini-css-extract-plugin": "^0.4.1",
|
||||
"nprogress": "^0.2.0",
|
||||
"null-loader": "^1.0.0",
|
||||
"portfinder": "^1.0.13",
|
||||
"react-dev-utils": "^8.0.0",
|
||||
"react-helmet": "^6.0.0-beta",
|
||||
|
|
|
@ -9547,6 +9547,14 @@ nth-check@^1.0.2, nth-check@~1.0.1:
|
|||
dependencies:
|
||||
boolbase "~1.0.0"
|
||||
|
||||
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"
|
||||
|
||||
num2fraction@^1.2.2:
|
||||
version "1.2.2"
|
||||
resolved "https://registry.yarnpkg.com/num2fraction/-/num2fraction-1.2.2.tgz#6f682b6a027a4e9ddfa4564cd2589d1d4e669ede"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue