mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Update extract-text-webpack-plugin to 3.0 and add linting (#20151)
This commit is contained in:
committed by
Ryan Cavanaugh
parent
24290d9409
commit
56eb6380b4
@@ -1,10 +1,7 @@
|
||||
import { optimize, Configuration, Plugin } from 'webpack'
|
||||
|
||||
import * as ExtractTextPlugin from 'extract-text-webpack-plugin'
|
||||
|
||||
|
||||
let configuration: Configuration
|
||||
import webpack = require('webpack');
|
||||
import ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
|
||||
let configuration: webpack.Configuration;
|
||||
|
||||
configuration = {
|
||||
// The standard entry point and output config
|
||||
@@ -58,7 +55,7 @@ configuration = {
|
||||
configuration = {
|
||||
// ...
|
||||
plugins: [
|
||||
new optimize.CommonsChunkPlugin({
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: "commons",
|
||||
filename: "commons.js",
|
||||
}),
|
||||
@@ -85,15 +82,15 @@ configuration = {
|
||||
};
|
||||
|
||||
// multiple extract instances
|
||||
let extractCSS = new ExtractTextPlugin('stylesheets/[name].css');
|
||||
let extractLESS = new ExtractTextPlugin('stylesheets/[name].less');
|
||||
const extractCSS: ExtractTextPlugin = new ExtractTextPlugin('stylesheets/[name].css');
|
||||
const extractLESS: ExtractTextPlugin = new ExtractTextPlugin('stylesheets/[name].less');
|
||||
|
||||
configuration = {
|
||||
// ...
|
||||
module: {
|
||||
rules: [
|
||||
{ test: /\.scss$/i, use: extractCSS.extract(['css','sass']) },
|
||||
{ test: /\.less$/i, use: extractLESS.extract(['css','less']) },
|
||||
{ test: /\.scss$/i, use: extractCSS.extract(['css', 'sass']) },
|
||||
{ test: /\.less$/i, use: extractLESS.extract(['css', 'less']) },
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
|
||||
65
types/extract-text-webpack-plugin/index.d.ts
vendored
65
types/extract-text-webpack-plugin/index.d.ts
vendored
@@ -1,49 +1,56 @@
|
||||
// Type definitions for extract-text-webpack-plugin 2.1.0
|
||||
// Type definitions for extract-text-webpack-plugin 3.0
|
||||
// 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, NewLoader } from 'webpack'
|
||||
import webpack = require('webpack');
|
||||
|
||||
export = ExtractTextPlugin;
|
||||
|
||||
/**
|
||||
* 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 | NewLoader
|
||||
|
||||
interface ExtractPluginOptions {
|
||||
/** the filename of the result file. May contain `[name]`, `[id]` and `[contenthash]` */
|
||||
filename: string
|
||||
/** extract from all additional chunks too (by default it extracts only from the initial chunk(s)) */
|
||||
allChunks?: boolean
|
||||
/** disables the plugin */
|
||||
disable?: boolean
|
||||
/** Unique ident for this plugin instance. (For advanced usage only, by default automatically generated) */
|
||||
id?: string
|
||||
}
|
||||
|
||||
interface ExtractOptions {
|
||||
/** the loader(s) that should be used for converting the resource to a css exporting module */
|
||||
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`) */
|
||||
fallback?: Loader | Loader[]
|
||||
/** override the `publicPath` setting for this loader */
|
||||
publicPath?: string
|
||||
}
|
||||
type Loader = string | webpack.OldLoader | webpack.NewLoader;
|
||||
|
||||
/**
|
||||
* Use an `ExtractTextPlugin` instance and a loader returned by `extract` in concert to write files to disk instead of loading them into others.
|
||||
* Usage example at https://github.com/webpack/extract-text-webpack-plugin#usage-example-with-css
|
||||
*/
|
||||
interface ExtractTextPlugin extends Plugin {
|
||||
declare class ExtractTextPlugin extends webpack.Plugin {
|
||||
/** Create a plugin instance defining the extraction target file(s) for the files loaded by `extract` */
|
||||
new (options: string | ExtractPluginOptions): ExtractTextPlugin
|
||||
constructor(options: string | ExtractTextPlugin.PluginOptions);
|
||||
/**
|
||||
* Creates an extracting loader from an existing loader.
|
||||
* Creates an extracting loader from an existing loader (static).
|
||||
* Use the resulting loader in `module.rules`/`module.loaders`.
|
||||
* @see {@link https://www.npmjs.com/package/extract-text-webpack-plugin#extract}
|
||||
*/
|
||||
extract: (loader: Loader | Loader[] | ExtractOptions) => Loader[]
|
||||
static extract: (loader: Loader | Loader[] | ExtractTextPlugin.LoaderOptions) => Loader[];
|
||||
/**
|
||||
* Creates an extracting loader from an existing loader (instance).
|
||||
* Use the resulting loader in `module.rules`/`module.loaders`.
|
||||
* @see {@link https://www.npmjs.com/package/extract-text-webpack-plugin#multiple-instances}
|
||||
*/
|
||||
extract: (loader: Loader | Loader[] | ExtractTextPlugin.LoaderOptions) => Loader[];
|
||||
}
|
||||
|
||||
declare const extractTextPlugin: ExtractTextPlugin
|
||||
export = extractTextPlugin
|
||||
declare namespace ExtractTextPlugin {
|
||||
interface PluginOptions {
|
||||
/** the filename of the result file. May contain `[name]`, `[id]` and `[contenthash]` */
|
||||
filename: string;
|
||||
/** extract from all additional chunks too (by default it extracts only from the initial chunk(s)) */
|
||||
allChunks?: boolean;
|
||||
/** disables the plugin */
|
||||
disable?: boolean;
|
||||
/** Unique ident for this plugin instance. (For advanced usage only, by default automatically generated) */
|
||||
id?: string;
|
||||
}
|
||||
interface LoaderOptions {
|
||||
/** the loader(s) that should be used for converting the resource to a css exporting module */
|
||||
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`) */
|
||||
fallback?: Loader | Loader[];
|
||||
/** override the `publicPath` setting for this loader */
|
||||
publicPath?: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,4 +19,4 @@
|
||||
"index.d.ts",
|
||||
"extract-text-webpack-plugin-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
1
types/extract-text-webpack-plugin/tslint.json
Normal file
1
types/extract-text-webpack-plugin/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user