mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 11:57:33 +08:00
add definition for mini-css-extract-plugin
This commit is contained in:
32
types/mini-css-extract-plugin/index.d.ts
vendored
Normal file
32
types/mini-css-extract-plugin/index.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
// Type definitions for mini-css-extract-plugin 0.2
|
||||
// Project: https://github.com/webpack-contrib/mini-css-extract-plugin
|
||||
// Definitions by: JounQin <https://github.com/JounQin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Loader, Plugin } from 'webpack';
|
||||
|
||||
/**
|
||||
* Lightweight CSS extraction webpack plugin
|
||||
* This plugin extract CSS into separate files. It creates a CSS file per JS file which contains CSS. It supports On-Demand-Loading of CSS and SourceMaps.
|
||||
* Configuration Detail: https://github.com/webpack-contrib/mini-css-extract-plugin#configuration
|
||||
*/
|
||||
declare class MiniCssExtractPlugin extends Plugin {
|
||||
/** webpack loader used always at the end of loaders list */
|
||||
static loader: Loader;
|
||||
|
||||
constructor(options?: MiniCssExtractPlugin.PluginOptions);
|
||||
}
|
||||
|
||||
declare namespace MiniCssExtractPlugin {
|
||||
interface PluginOptions {
|
||||
/**
|
||||
* Options similar to the same options in webpackOptions.output, both options are optional
|
||||
* May contain `[name]`, `[id]`, `hash` and `[chunkhash]`
|
||||
*/
|
||||
filename?: string;
|
||||
chunkFilename?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export = MiniCssExtractPlugin;
|
||||
@@ -0,0 +1,58 @@
|
||||
import webpack = require('webpack');
|
||||
import MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
|
||||
let configuration: webpack.Configuration;
|
||||
|
||||
configuration = {
|
||||
// The standard entry point and output config
|
||||
entry: {
|
||||
posts: './posts',
|
||||
post: './post',
|
||||
about: './about',
|
||||
},
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
chunkFilename: '[id].js',
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
// Extract css files
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [MiniCssExtractPlugin.loader, 'css-loader'],
|
||||
},
|
||||
// Optionally extract less files
|
||||
// or any other compile-to-css language
|
||||
{
|
||||
test: /\.less$/,
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
'css-loader',
|
||||
'style-loader',
|
||||
],
|
||||
},
|
||||
// You could also use other loaders the same way. I. e. the autoprefixer-loader
|
||||
],
|
||||
},
|
||||
// Use the plugin to specify the resulting filename (and add needed behavior to the compiler)
|
||||
plugins: [
|
||||
new MiniCssExtractPlugin({
|
||||
filename: '[name].css',
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
configuration = {
|
||||
// ...
|
||||
plugins: [new MiniCssExtractPlugin()],
|
||||
};
|
||||
|
||||
configuration = {
|
||||
// ...
|
||||
plugins: [
|
||||
new MiniCssExtractPlugin({
|
||||
filename: 'styles.css',
|
||||
chunkFilename: 'style.css',
|
||||
}),
|
||||
],
|
||||
};
|
||||
23
types/mini-css-extract-plugin/tsconfig.json
Normal file
23
types/mini-css-extract-plugin/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"mini-css-extract-plugin-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/mini-css-extract-plugin/tslint.json
Normal file
1
types/mini-css-extract-plugin/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user