nav tabs on admin dashboard
This commit is contained in:
+81
-33
@@ -14,11 +14,11 @@
|
||||
<img width="200" height="200"
|
||||
src="https://webpack.js.org/assets/icon-square-big.svg">
|
||||
</a>
|
||||
<h1>SASS Loader</h1>
|
||||
<p>Loads a SASS/SCSS file and compiles it to CSS.</p>
|
||||
<h1>Sass Loader</h1>
|
||||
<p>Loads a Sass/SCSS file and compiles it to CSS.</p>
|
||||
</div>
|
||||
|
||||
Use the [css-loader](https://github.com/webpack-contrib/css-loader) or the [raw-loader](https://github.com/webpack-contrib/raw-loader) to turn it into a JS module and the [ExtractTextPlugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) to extract it into a separate file.
|
||||
Use the [css-loader](https://github.com/webpack-contrib/css-loader) or the [raw-loader](https://github.com/webpack-contrib/raw-loader) to turn it into a JS module and the [MiniCssExtractPlugin](https://github.com/webpack-contrib/mini-css-extract-plugin) to extract it into a separate file.
|
||||
Looking for the webpack 1 loader? Check out the [archive/webpack-1 branch](https://github.com/webpack-contrib/sass-loader/tree/archive/webpack-1).
|
||||
|
||||
<h2 align="center">Install</h2>
|
||||
@@ -27,8 +27,14 @@ Looking for the webpack 1 loader? Check out the [archive/webpack-1 branch](https
|
||||
npm install sass-loader node-sass webpack --save-dev
|
||||
```
|
||||
|
||||
The sass-loader requires [node-sass](https://github.com/sass/node-sass) and [webpack](https://github.com/webpack)
|
||||
as [`peerDependency`](https://docs.npmjs.com/files/package.json#peerdependencies). Thus you are able to control the versions accurately.
|
||||
The sass-loader requires [webpack](https://github.com/webpack) as a
|
||||
[`peerDependency`](https://docs.npmjs.com/files/package.json#peerdependencies)
|
||||
and it requires you to install either [Node Sass][] or [Dart Sass][] on your
|
||||
own. This allows you to control the versions of all your dependencies, and to
|
||||
choose which Sass implementation to use.
|
||||
|
||||
[Node Sass]: https://github.com/sass/node-sass
|
||||
[Dart Sass]: http://sass-lang.com/dart-sass
|
||||
|
||||
<h2 align="center">Examples</h2>
|
||||
|
||||
@@ -45,19 +51,17 @@ module.exports = {
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.scss$/,
|
||||
use: [{
|
||||
loader: "style-loader" // creates style nodes from JS strings
|
||||
}, {
|
||||
loader: "css-loader" // translates CSS into CommonJS
|
||||
}, {
|
||||
loader: "sass-loader" // compiles Sass to CSS
|
||||
}]
|
||||
use: [
|
||||
"style-loader", // creates style nodes from JS strings
|
||||
"css-loader", // translates CSS into CommonJS
|
||||
"sass-loader" // compiles Sass to CSS, using Node Sass by default
|
||||
]
|
||||
}]
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
You can also pass options directly to [node-sass](https://github.com/andrew/node-sass) by specifying an `options` property like this:
|
||||
You can also pass options directly to [Node Sass][] or [Dart Sass][]:
|
||||
|
||||
```js
|
||||
// webpack.config.js
|
||||
@@ -81,38 +85,82 @@ module.exports = {
|
||||
};
|
||||
```
|
||||
|
||||
See [node-sass](https://github.com/andrew/node-sass) for all available Sass options.
|
||||
See [the Node Sass documentation](https://github.com/sass/node-sass/blob/master/README.md#options) for all available Sass options.
|
||||
|
||||
### In production
|
||||
|
||||
Usually, it's recommended to extract the style sheets into a dedicated file in production using the [ExtractTextPlugin](https://github.com/webpack-contrib/extract-text-webpack-plugin). This way your styles are not dependent on JavaScript:
|
||||
The special `implementation` option determines which implementation of Sass to
|
||||
use. It takes either a [Node Sass][] or a [Dart Sass][] module. For example, to
|
||||
use Dart Sass, you'd pass:
|
||||
|
||||
```js
|
||||
const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
||||
// ...
|
||||
{
|
||||
loader: "sass-loader",
|
||||
options: {
|
||||
implementation: require("sass")
|
||||
}
|
||||
}
|
||||
// ...
|
||||
```
|
||||
|
||||
const extractSass = new ExtractTextPlugin({
|
||||
filename: "[name].[contenthash].css",
|
||||
disable: process.env.NODE_ENV === "development"
|
||||
});
|
||||
Note that when using Dart Sass, **synchronous compilation is twice as fast as
|
||||
asynchronous compilation** by default, due to the overhead of asynchronous
|
||||
callbacks. To avoid this overhead, you can use the
|
||||
[`fibers`](https://www.npmjs.com/package/fibers) package to call asynchronous
|
||||
importers from the synchronous code path. To enable this, pass the `Fiber` class
|
||||
to the `fiber` option:
|
||||
|
||||
```js
|
||||
// webpack.config.js
|
||||
const Fiber = require('fibers');
|
||||
|
||||
module.exports = {
|
||||
...
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.scss$/,
|
||||
use: extractSass.extract({
|
||||
use: [{
|
||||
loader: "css-loader"
|
||||
}, {
|
||||
loader: "sass-loader"
|
||||
}],
|
||||
// use style-loader in development
|
||||
fallback: "style-loader"
|
||||
})
|
||||
use: [{
|
||||
loader: "style-loader"
|
||||
}, {
|
||||
loader: "css-loader"
|
||||
}, {
|
||||
loader: "sass-loader",
|
||||
options: {
|
||||
implementation: require("sass"),
|
||||
fiber: Fiber
|
||||
}
|
||||
}]
|
||||
}]
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### In production
|
||||
|
||||
Usually, it's recommended to extract the style sheets into a dedicated file in production using the [MiniCssExtractPlugin](https://github.com/webpack-contrib/mini-css-extract-plugin). This way your styles are not dependent on JavaScript:
|
||||
|
||||
```js
|
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||
|
||||
module.exports = {
|
||||
...
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.scss$/,
|
||||
use: [
|
||||
// fallback to style-loader in development
|
||||
process.env.NODE_ENV !== 'production' ? 'style-loader' : MiniCssExtractPlugin.loader,
|
||||
"css-loader",
|
||||
"sass-loader"
|
||||
]
|
||||
}]
|
||||
},
|
||||
plugins: [
|
||||
extractSass
|
||||
new MiniCssExtractPlugin({
|
||||
// Options similar to the same options in webpackOptions.output
|
||||
// both options are optional
|
||||
filename: "[name].css",
|
||||
chunkFilename: "[id].css"
|
||||
})
|
||||
]
|
||||
};
|
||||
```
|
||||
@@ -121,7 +169,7 @@ module.exports = {
|
||||
|
||||
### Imports
|
||||
|
||||
webpack provides an [advanced mechanism to resolve files](https://webpack.js.org/concepts/module-resolution/). The sass-loader uses node-sass' custom importer feature to pass all queries to the webpack resolving engine. Thus you can import your Sass modules from `node_modules`. Just prepend them with a `~` to tell webpack that this is not a relative import:
|
||||
webpack provides an [advanced mechanism to resolve files](https://webpack.js.org/concepts/module-resolution/). The sass-loader uses Sass's custom importer feature to pass all queries to the webpack resolving engine. Thus you can import your Sass modules from `node_modules`. Just prepend them with a `~` to tell webpack that this is not a relative import:
|
||||
|
||||
```css
|
||||
@import "~bootstrap/dist/css/bootstrap";
|
||||
|
||||
Reference in New Issue
Block a user