add definition for mini-css-extract-plugin

This commit is contained in:
Jiaren Liu
2018-03-23 13:48:42 +08:00
parent f2982c1754
commit c7b0505170
4 changed files with 114 additions and 0 deletions

View 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;

View File

@@ -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',
}),
],
};

View 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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }