Updated extract-text-webpack-plugin definition

This commit is contained in:
Kayo Phoenix 2017-02-20 15:54:16 +05:00
parent 755fad105c
commit 592e1d4f9b
2 changed files with 21 additions and 18 deletions

View File

@ -22,18 +22,18 @@ configuration = {
// Extract css files
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: "style-loader",
loader: "css-loader",
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader",
})
},
// Optionally extract less files
// or any other compile-to-css language
{
test: /\.less$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: "style-loader",
loader: ["css-loader", "less-loader"],
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: ["css-loader", "less-loader"],
})
}
// You could also use other loaders the same way. I. e. the autoprefixer-loader
@ -70,10 +70,13 @@ configuration = {
// ...
module: {
rules: [
{ test: /\.css$/, loader: ExtractTextPlugin.extract({
fallbackLoader: "style-loader",
loader: "css-loader"
}) }
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
}
]
},
plugins: [
@ -89,8 +92,8 @@ configuration = {
// ...
module: {
rules: [
{ test: /\.scss$/i, loader: extractCSS.extract(['css','sass']) },
{ test: /\.less$/i, loader: extractLESS.extract(['css','less']) },
{ test: /\.scss$/i, use: extractCSS.extract(['css','sass']) },
{ test: /\.less$/i, use: extractLESS.extract(['css','less']) },
]
},
plugins: [

View File

@ -1,15 +1,15 @@
// Type definitions for extract-text-webpack-plugin 2.0.0
// Project: https://github.com/webpack/extract-text-webpack-plugin
// Definitions by: flying-sheep <https://github.com/flying-sheep>
// Project: https://github.com/webpack-contrib/extract-text-webpack-plugin
// Definitions by: flying-sheep <https://github.com/flying-sheep>, kayo <https://github.com/katyo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin, OldLoader } from 'webpack'
import { Plugin, OldLoader, NewLoader } from 'webpack'
/**
* extract-text-webpack-plugin has no support for .options instead of .query yet.
* See https://github.com/webpack/extract-text-webpack-plugin/issues/281
*/
type Loader = string | OldLoader
type Loader = string | OldLoader | NewLoader
interface ExtractPluginOptions {
/** the filename of the result file. May contain `[name]`, `[id]` and `[contenthash]` */
@ -24,9 +24,9 @@ interface ExtractPluginOptions {
interface ExtractOptions {
/** the loader(s) that should be used for converting the resource to a css exporting module */
loader: Loader | Loader[]
use: Loader | Loader[]
/** the loader(s) that should be used when the css is not extracted (i.e. in an additional chunk when `allChunks: false`) */
fallbackLoader?: Loader | Loader[]
fallback?: Loader | Loader[]
/** override the `publicPath` setting for this loader */
publicPath?: string
}