Create definitions for dotenv-webpack (#24828)

This commit is contained in:
Karol Majewski
2018-04-09 18:47:24 +02:00
committed by Mohamed Hegazy
parent 0a20ea4ad9
commit 6bd12e9136
4 changed files with 82 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import * as webpack from 'webpack';
import DotenvWebpackPlugin = require('dotenv-webpack');
new DotenvWebpackPlugin(); // $ExpectType DotenvWebpackPlugin
const options: DotenvWebpackPlugin.Options = {
path: './some.other.env',
safe: true,
systemvars: true,
silent: true
};
const config: webpack.Configuration = {
plugins: [
new DotenvWebpackPlugin(),
new DotenvWebpackPlugin({
path: './some.other.env',
}),
new DotenvWebpackPlugin(options),
]
};

37
types/dotenv-webpack/index.d.ts vendored Normal file
View File

@@ -0,0 +1,37 @@
// Type definitions for dotenv-webpack 1.5
// Project: https://github.com/mrsteele/dotenv-webpack
// Definitions by: Karol Majewski <https://github.com/karol-majewski>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7
import * as webpack from 'webpack';
declare class DotenvWebpackPlugin extends webpack.Plugin {
constructor(options?: DotenvWebpackPlugin.Options);
}
declare namespace DotenvWebpackPlugin {
interface Options {
/**
* The path to your environment variables. Default: `'./.env'`.
*/
path?: string;
/**
* If `false` ignore safe-mode, if `true` load `'./.env.example'`, if a `string` load that file as the sample. Default: `false`.
*/
safe?: boolean;
/**
* Set to `true` if you would rather load all system variables as well (useful for CI purposes). Default: `false`.
*/
systemvars?: boolean;
/**
* If `true`, all warnings will be surpressed. Default: `false`.
*/
silent?: boolean;
}
}
export = DotenvWebpackPlugin;

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",
"dotenv-webpack-tests.ts"
]
}

View File

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