Type definitions for sass-webpack-plugin 1.0.0 (#23898)

* finish

* add tslint

* pass lint

* fix some error

* fix export error
This commit is contained in:
AEPKILL
2018-02-27 00:42:37 +08:00
committed by Andy
parent 6627256182
commit 385efad406
4 changed files with 80 additions and 0 deletions

32
types/sass-webpack-plugin/index.d.ts vendored Normal file
View File

@@ -0,0 +1,32 @@
// Type definitions for sass-webpack-plugin 1.0
// Project: https://github.com/jalkoby/sass-webpack-plugin
// Definitions by: AEPKILL <https://github.com/AepKill>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
import { Options } from 'node-sass';
import { Plugin } from 'webpack';
declare namespace SassPlugin {
type NODE_ENV = 'production' | 'development';
type FileRule = string | string[] | { [key: string]: string };
interface Config {
sourceMap?: boolean;
autoprefixer?: boolean;
sass?: Options;
}
}
declare class SassPlugin extends Plugin {
constructor(
file: SassPlugin.FileRule,
mode?: SassPlugin.NODE_ENV | SassPlugin.Config
);
constructor(
file: SassPlugin.FileRule,
mode: SassPlugin.NODE_ENV,
config?: SassPlugin.Config
);
}
export = SassPlugin;

View File

@@ -0,0 +1,30 @@
import SassPlugin = require('sass-webpack-plugin');
type NODE_ENV = SassPlugin.NODE_ENV;
const env = process.env.NODE_ENV as NODE_ENV;
new SassPlugin('./src/styles/index.scss');
// production ready
new SassPlugin('./src/styles/index.scss', env);
// multi files
new SassPlugin(['./src/styles/one.scss', './src/styles/two.sass'], env);
// a different output filename
new SassPlugin({ './src/styles/index.scss': 'bundle.css' }, env);
// with sass tuning
new SassPlugin('./src/styles/index.scss', env, {
sass: {
includePaths: ['node_modules/bootstrap-sass/assets/stylesheets']
}
});
// with source maps + compressing - autoprefixing
new SassPlugin('./src/styles/index.scss', {
sourceMap: true,
sass: { outputStyle: 'compressed' },
autoprefixer: false
});

View File

@@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6", "dom"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"jsx": "react",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "sass-webpack-plugin-tests.ts"]
}

View File

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