diff --git a/types/dotenv-webpack/dotenv-webpack-tests.ts b/types/dotenv-webpack/dotenv-webpack-tests.ts new file mode 100644 index 0000000000..6605550529 --- /dev/null +++ b/types/dotenv-webpack/dotenv-webpack-tests.ts @@ -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), + ] +}; diff --git a/types/dotenv-webpack/index.d.ts b/types/dotenv-webpack/index.d.ts new file mode 100644 index 0000000000..2d330ace45 --- /dev/null +++ b/types/dotenv-webpack/index.d.ts @@ -0,0 +1,37 @@ +// Type definitions for dotenv-webpack 1.5 +// Project: https://github.com/mrsteele/dotenv-webpack +// Definitions by: 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; diff --git a/types/dotenv-webpack/tsconfig.json b/types/dotenv-webpack/tsconfig.json new file mode 100644 index 0000000000..f87dcd737b --- /dev/null +++ b/types/dotenv-webpack/tsconfig.json @@ -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" + ] +} diff --git a/types/dotenv-webpack/tslint.json b/types/dotenv-webpack/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/dotenv-webpack/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }