Added type for @webpack-blocks/core (#39006)

* created draft for @types/webpack-blocks__core

* corrected formatting

* added tests to typing

* corrected formatting; fixed import

* - implemented definitions for webpack-blocks package.

* - implemented definitions for webpack-blocks package.

* - corrected formatting for import/export in main package.

* - corrected formatting tests for assets.

* - added declarations for @webpack-blocks/babel plugin.

* - updated tests for babel.

* - updated tests for babel subpackage.

* - implemented dev-server type

* - updated description for babel.

* - corrected formatting.

* - implemented definition for webpack-blocks/extract-text package.

* - corrected formatting

* - implemented webpack module for webpack-blocks

* - proxied more methods.

* - corrected formatting.

* - implemented definitions for @webpack-blocks/postcss package.

* - corrected formatting.

* - corrected type description.

* - implemented definition for @webpack-blocks/sass package.

* - corrected formatting.

* - implemented draft definitions for webpack-blocks/typescript package.

* - implemented draft definitions for webpack-blocks/uglify package.

* - updated interface for typescript;
- corrected name and formatting for tests.

* - corrected name for tests.

* - corrected link to package;
- corrected formatting;
- removed redundant module.exports from test.

* - corrected typings for @webpack-blocks/uglify.

* - corrected namings.

* - corrected import and version.

* - corrected import and version.

* - corrected import and version.

* - simplified type.

* - corrected imports.
This commit is contained in:
Max Boguslavsky 2019-10-17 01:14:42 +03:00 committed by Andrew Branch
parent 5c4192c3b2
commit d067c52e79
43 changed files with 1082 additions and 0 deletions

77
types/webpack-blocks/index.d.ts vendored Normal file
View File

@ -0,0 +1,77 @@
// Type definitions for webpack-blocks 2.0
// Project: https://github.com/andywer/webpack-blocks
// Definitions by: Max Boguslavskiy <https://github.com/maxbogus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { css, url, file } from '@webpack-blocks/assets';
import babel = require('@webpack-blocks/babel');
import devServer = require('@webpack-blocks/dev-server');
import extractText = require('@webpack-blocks/extract-text');
import postcss = require('@webpack-blocks/postcss');
import sass = require('@webpack-blocks/sass');
import typescript = require('@webpack-blocks/typescript');
import uglify = require('@webpack-blocks/uglify');
import {
Block,
group,
createConfig,
setMode,
addPlugins,
customConfig,
defineConstants,
setEnv,
entryPoint,
performance,
optimization,
resolve,
setContext,
setDevTool,
setOutput,
sourceMaps,
InitialContext,
Context,
Util,
MatchOptions,
ConfigSetter,
env,
match,
when,
} from '@webpack-blocks/webpack';
export {
Block,
group,
createConfig,
setMode,
addPlugins,
customConfig,
defineConstants,
setEnv,
entryPoint,
performance,
optimization,
resolve,
setContext,
setDevTool,
setOutput,
sourceMaps,
InitialContext,
Context,
Util,
MatchOptions,
ConfigSetter,
env,
match,
when,
css,
url,
file,
babel,
devServer,
extractText,
postcss,
sass,
typescript,
uglify,
};

View File

@ -0,0 +1,35 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"esModuleInterop": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@webpack-blocks/assets": ["webpack-blocks__assets"],
"@webpack-blocks/babel": ["webpack-blocks__babel"],
"@webpack-blocks/core": ["webpack-blocks__core"],
"@webpack-blocks/dev-server": ["webpack-blocks__dev-server"],
"@webpack-blocks/extract-text": ["webpack-blocks__extract-text"],
"@webpack-blocks/postcss": ["webpack-blocks__postcss"],
"@webpack-blocks/sass": ["webpack-blocks__sass"],
"@webpack-blocks/typescript": ["webpack-blocks__typescript"],
"@webpack-blocks/uglify": ["webpack-blocks__uglify"],
"@webpack-blocks/webpack": ["webpack-blocks__webpack"]
}
},
"files": [
"index.d.ts"
]
}

View File

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

68
types/webpack-blocks__assets/index.d.ts vendored Normal file
View File

@ -0,0 +1,68 @@
// Type definitions for @webpack-blocks/assets 2.0
// Project: https://github.com/andywer/webpack-blocks/tree/master/packages/assets
// Definitions by: Max Boguslavskiy <https://github.com/maxbogus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { Block } from 'webpack-blocks';
export namespace css {
type UrlFilter = (url: string, resourcePath: string) => boolean;
type ImportFilter = (parseImport: ParseImportOptions, resourcePath: string) => boolean;
type GetLocalIdent = (context: any, localIdentName: any, localName: any, options: any) => string;
type NameFunction = (file: string) => any;
type PathFunction = (url: string, resourcePath: string, context: string) => any;
interface ParseImportOptions {
url: string;
media: string;
}
interface ModuleOptions {
mode?: string;
localIdentName?: string;
context?: string;
hashPrefix?: string;
getLocalIdent?: GetLocalIdent;
localIdentRegExp?: string | RegExp;
/**
* 0 => no loaders (default);
* 1 => postcss-loader;
* 2 => postcss-loader, sass-loader
*/
importLoaders?: 0 | 1 | 2;
localsConvention?: 'asIs' | 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
onlyLocals?: boolean;
}
interface CssOptions {
url?: boolean | UrlFilter;
import?: boolean | ImportFilter;
modules?: boolean | string | ModuleOptions;
sourceMap?: boolean;
}
interface FileOptions {
name?: string | NameFunction;
outputPath?: string | PathFunction;
publicPath?: string | PathFunction;
postTransformPublicPath?: (p: string) => string;
context?: string;
emitFile?: boolean;
regExp?: RegExp;
}
interface UrlOptions {
fallback?: string;
limit?: number | boolean | string;
mimetype?: string;
}
function modules(options?: ModuleOptions): any;
}
export function css(options?: css.CssOptions): Block;
export function file(options?: css.FileOptions): Block;
export function url(options?: css.UrlOptions): Block;

View File

@ -0,0 +1,36 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"esModuleInterop": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@webpack-blocks/assets": ["webpack-blocks__assets"],
"@webpack-blocks/babel": ["webpack-blocks__babel"],
"@webpack-blocks/core": ["webpack-blocks__core"],
"@webpack-blocks/dev-server": ["webpack-blocks__dev-server"],
"@webpack-blocks/extract-text": ["webpack-blocks__extract-text"],
"@webpack-blocks/postcss": ["webpack-blocks__postcss"],
"@webpack-blocks/sass": ["webpack-blocks__sass"],
"@webpack-blocks/typescript": ["webpack-blocks__typescript"],
"@webpack-blocks/uglify": ["webpack-blocks__uglify"],
"@webpack-blocks/webpack": ["webpack-blocks__webpack"]
}
},
"files": [
"index.d.ts",
"webpack-blocks__assets-tests.ts"
]
}

View File

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

View File

@ -0,0 +1,42 @@
import { css, file, url } from '@webpack-blocks/assets';
import { createConfig, match } from 'webpack-blocks';
// test data
const emptyCssOptions: css.CssOptions = {};
const filledCssOptions: css.CssOptions = {};
const emptyFileOptions: css.FileOptions = {};
const filledFileOptions: css.FileOptions = {};
const emptyUrlOptions: css.UrlOptions = {};
const filledUrlOptions: css.UrlOptions = {};
// tests
createConfig([
css(), // or use `match()` to apply it to other files than *.css
// will copy font files to build directory and link to them
match(['*.eot', '*.ttf', '*.woff', '*.woff2'], [file()]),
// will load images up to 10KB as data URL
match(['*.gif', '*.jpg', '*.jpeg', '*.png', '*.svg', '*.webp'], [url({ limit: 10000 })]),
]);
createConfig([
match(
['*.css', '!*node_modules*'],
[
css.modules({
localIdentName: '[name]--[local]--[hash:base64:5]',
}),
],
),
]);
css();
css(emptyCssOptions);
css(filledCssOptions);
file();
file(emptyFileOptions);
file(filledFileOptions);
url();
url(emptyUrlOptions);
url(filledUrlOptions);

17
types/webpack-blocks__babel/index.d.ts vendored Normal file
View File

@ -0,0 +1,17 @@
// Type definitions for @webpack-blocks/babel 2.0
// Project: https://github.com/andywer/webpack-blocks/tree/master/packages/babel
// Definitions by: Max Boguslavskiy <https://github.com/maxbogus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { Block } from 'webpack-blocks';
interface babel {
cacheDirectory?: boolean;
plugins?: string[];
presets?: string[];
}
declare function babel(options?: babel): Block;
export = babel;

View File

@ -0,0 +1,36 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"esModuleInterop": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@webpack-blocks/assets": ["webpack-blocks__assets"],
"@webpack-blocks/babel": ["webpack-blocks__babel"],
"@webpack-blocks/core": ["webpack-blocks__core"],
"@webpack-blocks/dev-server": ["webpack-blocks__dev-server"],
"@webpack-blocks/extract-text": ["webpack-blocks__extract-text"],
"@webpack-blocks/postcss": ["webpack-blocks__postcss"],
"@webpack-blocks/sass": ["webpack-blocks__sass"],
"@webpack-blocks/typescript": ["webpack-blocks__typescript"],
"@webpack-blocks/uglify": ["webpack-blocks__uglify"],
"@webpack-blocks/webpack": ["webpack-blocks__webpack"]
}
},
"files": [
"index.d.ts",
"webpack-blocks__babel-tests.ts"
]
}

View File

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

View File

@ -0,0 +1,6 @@
import { createConfig, match } from '@webpack-blocks/webpack';
import babel from '@webpack-blocks/babel';
createConfig([match(['*.js', '!*node_modules*'], [babel()])]);
createConfig([match(['*.js', '!*node_modules*'], [babel({ presets: [''], cacheDirectory: false, plugins: [''] })])]);

62
types/webpack-blocks__core/index.d.ts vendored Normal file
View File

@ -0,0 +1,62 @@
// Type definitions for @webpack-blocks/core 2.0
// Project: https://github.com/andywer/webpack-blocks/tree/master/packages/core
// Definitions by: Vladimir Grenaderov <https://github.com/VladimirGrenaderov>,
// Max Boguslavskiy <https://github.com/maxbogus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { Configuration, Plugin, RuleSetRule } from 'webpack';
export type ConfigSetter<T extends Context = Context> = (
context: T,
util: Util
) => (config: Configuration) => Configuration;
export interface Block<T extends Context = Context> extends ConfigSetter<T> {
pre?: ConfigSetter<T> | Array<ConfigSetter<T>>;
post?: ConfigSetter<T> | Array<ConfigSetter<T>>;
}
export interface Context {
match: {
test: RegExp | RegExp[];
};
}
export interface InitialContext {
webpack: any;
webpackVersion: string;
}
export interface MatchOptions {
include?: string;
exclude?: RegExp;
}
export interface Util {
addLoader(loaderDefinition: RuleSetRule): () => Configuration;
addPlugin(plugin: Plugin): () => Configuration;
merge(configSnippet: Configuration): () => Configuration;
}
export namespace Core {
function createConfig(configSetters: Block[]): Block;
function createConfig(initialContext: InitialContext, configSetters: Block[]): Block;
function group(configSetters: Block[]): Block;
function env(envName: string, configSetters: Block[]): Block;
function match(test: string | string[], configSetters: Block[]): Block;
function match(test: string | string[], options: MatchOptions, configSetters: Block[]): Block;
function when(condition: boolean, configSetters: Block[]): Block;
}
export function createConfig(configSetters: Block[]): Block;
export function createConfig(initialContext: InitialContext, configSetters: Block[]): Block;
export function group(configSetters: Block[]): Block;
export function env(envName: string, configSetters: Block[]): Block;
export function match(test: string | string[], configSetters: Block[]): Block;
export function match(test: string | string[], options: MatchOptions, configSetters: Block[]): Block;
export function when(condition: boolean, configSetters: Block[]): Block;

View File

@ -0,0 +1,36 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"esModuleInterop": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@webpack-blocks/assets": ["webpack-blocks__assets"],
"@webpack-blocks/babel": ["webpack-blocks__babel"],
"@webpack-blocks/core": ["webpack-blocks__core"],
"@webpack-blocks/dev-server": ["webpack-blocks__dev-server"],
"@webpack-blocks/extract-text": ["webpack-blocks__extract-text"],
"@webpack-blocks/postcss": ["webpack-blocks__postcss"],
"@webpack-blocks/sass": ["webpack-blocks__sass"],
"@webpack-blocks/typescript": ["webpack-blocks__typescript"],
"@webpack-blocks/uglify": ["webpack-blocks__uglify"],
"@webpack-blocks/webpack": ["webpack-blocks__webpack"]
}
},
"files": [
"index.d.ts",
"webpack-blocks__core-tests.ts"
]
}

View File

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

View File

@ -0,0 +1,34 @@
import { createConfig, group, env, match, when, Block, Context, MatchOptions, Util } from '@webpack-blocks/core';
import { Configuration } from 'webpack';
import { css, file, url } from 'webpack-blocks';
import babel from '@webpack-blocks/babel';
// test data
const block = (config: Configuration): Block => {
return (context: Context, util: Util) => util.merge(config);
};
const config: Configuration = {};
const blocks: Block[] = [block(config)];
const emptyMatchOptions: MatchOptions = {};
const filledMatchOptions: MatchOptions = {exclude: new RegExp(''), include: ''};
// tests
createConfig({webpack: null, webpackVersion: ''}, blocks);
createConfig([
css(),
match(['*.eot', '*.ttf', '*.woff', '*.woff2'], [file()]),
match(['*.gif', '*.jpg', '*.jpeg', '*.png', '*.svg', '*.webp'], [url({ limit: 10000 })]),
]);
createConfig([match(['*.js', '!*node_modules*'], [babel()])]);
group([]);
group(blocks);
env('production', blocks);
match('', blocks);
match('', emptyMatchOptions, blocks);
match('', filledMatchOptions, blocks);
match([], []);
when(true, blocks);

View File

@ -0,0 +1,102 @@
// Type definitions for @webpack-blocks/dev-server 2.0
// Project: https://github.com/andywer/webpack-blocks/tree/master/packages/dev-server
// Definitions by: Max Boguslavskiy <https://github.com/maxbogus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { Block } from 'webpack-blocks';
declare namespace devServer {
type InjectClientFunction = (compilerConfig: any) => boolean;
type PathFunction = () => string;
type ProxyFunction = (request: any, response: any, proxy: any) => null | undefined | false | string;
type ProxyType = object | ProxyFunction;
type RewritesToFunction = (context: ContextObject) => string;
type SetHeadersFunction = (res: object, path: string, stat: object) => void;
type StartMiddlewareFunction = (app: any, server: any) => void;
type WriteToDiskFunction = (filePath: string) => boolean;
interface ContextObject {
parsedUrl: any;
match: any;
request: any;
}
interface RewritesObject {
from: RegExp;
to: string | RewritesToFunction;
}
interface HistoryOptions {
index?: string;
rewrites?: RewritesObject;
verbose?: boolean;
htmlAcceptHeaders?: string[];
disableDotRule?: boolean;
}
interface TransportMode {
client?: string | PathFunction;
server?: string | PathFunction;
}
interface WatchOptions {
aggregateTimeout?: number;
ignored?: RegExp;
poll?: boolean | number;
}
interface Options {
after?: StartMiddlewareFunction;
allowedHosts?: string[];
before?: StartMiddlewareFunction;
bonjour?: boolean;
clientLogLevel?: 'silent' | 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'none' | 'warning';
compress?: boolean;
contentBase?: boolean | string | string [] | number;
disableHostCheck?: boolean;
filename?: string;
headers?: object;
historyApiFallback?: boolean | HistoryOptions;
host?: string;
hot?: boolean;
hotOnly?: boolean;
http2?: boolean;
https?: boolean | object;
index?: string;
injectClient?: boolean | InjectClientFunction;
injectHot?: boolean | InjectClientFunction;
inline?: boolean;
lazy?: boolean;
liveReload?: boolean;
mimeTypes?: { string: string[] };
noInfo?: boolean;
open?: boolean | string;
openPage?: string;
overlay?: boolean | { errors?: boolean, warnings?: boolean };
pfx?: string;
pfxPassphrase?: string;
port?: number;
proxy?: object | ProxyType[];
public?: string;
publicPath?: string;
quiet?: boolean;
serveIndex?: boolean;
setup?: InjectClientFunction;
socket?: string;
socketHost?: string;
socketPath?: string;
socketPort?: number | string;
staticOptions?: SetHeadersFunction;
stats?: 'none' | 'errors-only' | 'minimal' | 'normal' | 'verbose' | object;
transportMode?: 'sockjs' | 'ws' | TransportMode;
useLocalIp?: boolean;
watchContentBase?: boolean;
watchOptions?: WatchOptions;
writeToDisk?: boolean | WriteToDiskFunction;
}
}
declare function devServer(options?: devServer.Options, entry?: string | string[]): Block;
export = devServer;

View File

@ -0,0 +1,36 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"esModuleInterop": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@webpack-blocks/assets": ["webpack-blocks__assets"],
"@webpack-blocks/babel": ["webpack-blocks__babel"],
"@webpack-blocks/core": ["webpack-blocks__core"],
"@webpack-blocks/dev-server": ["webpack-blocks__dev-server"],
"@webpack-blocks/extract-text": ["webpack-blocks__extract-text"],
"@webpack-blocks/postcss": ["webpack-blocks__postcss"],
"@webpack-blocks/sass": ["webpack-blocks__sass"],
"@webpack-blocks/typescript": ["webpack-blocks__typescript"],
"@webpack-blocks/uglify": ["webpack-blocks__uglify"],
"@webpack-blocks/webpack": ["webpack-blocks__webpack"]
}
},
"files": [
"index.d.ts",
"webpack-blocks__dev-server-tests.ts"
]
}

View File

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

View File

@ -0,0 +1,13 @@
import { createConfig, env } from '@webpack-blocks/webpack';
import devServer from '@webpack-blocks/dev-server';
createConfig([
env('development', [
devServer({
overlay: true,
proxy: {
'/api': { target: 'http://localhost:3000' },
},
}),
]),
]);

View File

@ -0,0 +1,11 @@
// Type definitions for @webpack-blocks/extract-text 2.0
// Project: https://github.com/andywer/webpack-blocks/tree/master/packages/extract-text
// Definitions by: Max Boguslavskiy <https://github.com/maxbogus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { Block } from 'webpack-blocks';
declare function extractText(outputFilePattern?: string): Block;
export = extractText;

View File

@ -0,0 +1,36 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"esModuleInterop": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@webpack-blocks/assets": ["webpack-blocks__assets"],
"@webpack-blocks/babel": ["webpack-blocks__babel"],
"@webpack-blocks/core": ["webpack-blocks__core"],
"@webpack-blocks/dev-server": ["webpack-blocks__dev-server"],
"@webpack-blocks/extract-text": ["webpack-blocks__extract-text"],
"@webpack-blocks/postcss": ["webpack-blocks__postcss"],
"@webpack-blocks/sass": ["webpack-blocks__sass"],
"@webpack-blocks/typescript": ["webpack-blocks__typescript"],
"@webpack-blocks/uglify": ["webpack-blocks__uglify"],
"@webpack-blocks/webpack": ["webpack-blocks__webpack"]
}
},
"files": [
"index.d.ts",
"webpack-blocks__extract-text-tests.ts"
]
}

View File

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

View File

@ -0,0 +1,7 @@
import { createConfig, match, env } from '@webpack-blocks/webpack';
import extractText from '@webpack-blocks/extract-text';
import { css } from '@webpack-blocks/assets';
createConfig([extractText('path/to/output.file')]);
createConfig([match('*.css', [css(), env('production', [extractText()])])]);

View File

@ -0,0 +1,28 @@
// Type definitions for @webpack-blocks/postcss 2.0
// Project: https://github.com/andywer/webpack-blocks/tree/master/packages/postcss
// Definitions by: Max Boguslavskiy <https://github.com/maxbogus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { Block } from 'webpack-blocks';
declare namespace postCss {
type FunctionType = () => string;
interface Plugin {
parser?: string | FunctionType;
syntax?: string | FunctionType;
stringifier?: string | FunctionType;
}
interface Options {
parser?: string;
stringifier?: string;
syntax?: string;
plugins?: any[];
}
}
declare function postCss(options?: postCss.Options): Block;
export = postCss;

View File

@ -0,0 +1,36 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"esModuleInterop": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@webpack-blocks/assets": ["webpack-blocks__assets"],
"@webpack-blocks/babel": ["webpack-blocks__babel"],
"@webpack-blocks/core": ["webpack-blocks__core"],
"@webpack-blocks/dev-server": ["webpack-blocks__dev-server"],
"@webpack-blocks/extract-text": ["webpack-blocks__extract-text"],
"@webpack-blocks/postcss": ["webpack-blocks__postcss"],
"@webpack-blocks/sass": ["webpack-blocks__sass"],
"@webpack-blocks/typescript": ["webpack-blocks__typescript"],
"@webpack-blocks/uglify": ["webpack-blocks__uglify"],
"@webpack-blocks/webpack": ["webpack-blocks__webpack"]
}
},
"files": [
"index.d.ts",
"webpack-blocks__postcss-tests.ts"
]
}

View File

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

View File

@ -0,0 +1,12 @@
import { createConfig, match } from '@webpack-blocks/webpack';
import { css } from '@webpack-blocks/assets';
import postcss from '@webpack-blocks/postcss';
createConfig([match(['*.css', '!*node_modules*'], [css(), postcss()])]);
createConfig([
css(),
postcss({
plugins: [],
}),
]);

20
types/webpack-blocks__sass/index.d.ts vendored Normal file
View File

@ -0,0 +1,20 @@
// Type definitions for @webpack-blocks/sass 2.0
// Project: https://github.com/andywer/webpack-blocks/tree/master/packages/sass
// Definitions by: Max Boguslavskiy <https://github.com/maxbogus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { Block } from 'webpack-blocks';
declare namespace sass {
interface Options {
includePaths?: string[];
indentedSyntax?: boolean;
outputStyle?: string;
sourceMap?: boolean;
}
}
declare function sass(options?: sass.Options): Block;
export = sass;

View File

@ -0,0 +1,36 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"esModuleInterop": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@webpack-blocks/assets": ["webpack-blocks__assets"],
"@webpack-blocks/babel": ["webpack-blocks__babel"],
"@webpack-blocks/core": ["webpack-blocks__core"],
"@webpack-blocks/dev-server": ["webpack-blocks__dev-server"],
"@webpack-blocks/extract-text": ["webpack-blocks__extract-text"],
"@webpack-blocks/postcss": ["webpack-blocks__postcss"],
"@webpack-blocks/sass": ["webpack-blocks__sass"],
"@webpack-blocks/typescript": ["webpack-blocks__typescript"],
"@webpack-blocks/uglify": ["webpack-blocks__uglify"],
"@webpack-blocks/webpack": ["webpack-blocks__webpack"]
}
},
"files": [
"index.d.ts",
"webpack-blocks__sass-tests.ts"
]
}

View File

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

View File

@ -0,0 +1,13 @@
import { createConfig, match, env } from '@webpack-blocks/webpack';
import { css } from '@webpack-blocks/assets';
import sass from '@webpack-blocks/sass';
import extractText from '@webpack-blocks/extract-text';
import postcss from '@webpack-blocks/postcss';
createConfig([match('*.scss', [css(), sass(), postcss({ plugins: [] })])]);
createConfig([match('*.scss', [css.modules(), sass()])]);
createConfig([match('*.scss', [css(), sass(), env('production', [extractText()])])]);
createConfig([match(['*.scss', '!*node_modules*'], [css(), sass()])]);

View File

@ -0,0 +1,40 @@
// Type definitions for @webpack-blocks/typescript 2.0
// Project: https://github.com/andywer/webpack-blocks/tree/master/packages/typescript
// Definitions by: Max Boguslavskiy <https://github.com/maxbogus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { Block } from 'webpack-blocks';
declare namespace typescript {
type CustomTransformersFunction = (program: any) => any;
interface BabelOptions {
babelrc?: boolean;
presets?: string[][] | Array<Array<{ targets?: string, modules?: boolean }>>;
}
interface Options {
silent?: boolean;
compiler?: string;
useTranspileModule?: boolean;
instance?: string;
configFileName?: string;
transpileOnly?: boolean;
errorsAsWarnings?: boolean;
forceIsolatedModules?: boolean;
ignoreDiagnostics?: number[];
useBabel?: boolean;
babelOptions?: BabelOptions;
babelCore?: string;
useCache?: boolean;
usePrecompiledFiles?: boolean;
cacheDirectory?: string;
reportFiles?: string[];
getCustomTransformers?: string | CustomTransformersFunction;
}
}
declare function typescript(options?: typescript.Options): Block;
export = typescript;

View File

@ -0,0 +1,36 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"esModuleInterop": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@webpack-blocks/assets": ["webpack-blocks__assets"],
"@webpack-blocks/babel": ["webpack-blocks__babel"],
"@webpack-blocks/core": ["webpack-blocks__core"],
"@webpack-blocks/dev-server": ["webpack-blocks__dev-server"],
"@webpack-blocks/extract-text": ["webpack-blocks__extract-text"],
"@webpack-blocks/postcss": ["webpack-blocks__postcss"],
"@webpack-blocks/sass": ["webpack-blocks__sass"],
"@webpack-blocks/typescript": ["webpack-blocks__typescript"],
"@webpack-blocks/uglify": ["webpack-blocks__uglify"],
"@webpack-blocks/webpack": ["webpack-blocks__webpack"]
}
},
"files": [
"index.d.ts",
"webpack-blocks__typescript-tests.ts"
]
}

View File

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

View File

@ -0,0 +1,4 @@
import { createConfig } from '@webpack-blocks/webpack';
import typescript from '@webpack-blocks/typescript';
createConfig([typescript()]);

39
types/webpack-blocks__uglify/index.d.ts vendored Normal file
View File

@ -0,0 +1,39 @@
// Type definitions for @webpack-blocks/uglify 2.0
// Project: https://github.com/andywer/webpack-blocks/tree/master/packages/uglify
// Definitions by: Max Boguslavskiy <https://github.com/maxbogus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { Block } from 'webpack-blocks';
import { MinifyOptions } from 'uglify-js';
declare namespace uglify {
type TestType = string | RegExp;
type ExtractCommentsFunction = (node: any, comment: any) => boolean | ExtractCommentsObject;
type FileNameFunction = (file: string) => string;
interface ExtractCommentsObject {
condition?: boolean | string | RegExp | ExtractCommentsFunction;
filename?: RegExp | FileNameFunction;
banner?: boolean | string | FileNameFunction;
}
interface Options {
test?: TestType | TestType[];
include?: TestType | TestType[];
exclude?: TestType | TestType[];
chunkFilter?: (chunk: any) => boolean;
cache?: string | boolean;
cacheKeys?: (defaultCacheKeys: any, file: any) => object;
parallel?: boolean | number;
sourceMap?: boolean;
minify?: (file: any, sourceMap: any) => {error: any, map: any, code: any, warnings: any, extractedComments: any};
uglifyOptions?: MinifyOptions;
extractComments?: boolean | string | RegExp | ExtractCommentsFunction;
warningsFilter?: (warning: any, source: any) => boolean;
}
}
declare function uglify(options?: uglify.Options): Block;
export = uglify;

View File

@ -0,0 +1,36 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"esModuleInterop": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@webpack-blocks/assets": ["webpack-blocks__assets"],
"@webpack-blocks/babel": ["webpack-blocks__babel"],
"@webpack-blocks/core": ["webpack-blocks__core"],
"@webpack-blocks/dev-server": ["webpack-blocks__dev-server"],
"@webpack-blocks/extract-text": ["webpack-blocks__extract-text"],
"@webpack-blocks/postcss": ["webpack-blocks__postcss"],
"@webpack-blocks/sass": ["webpack-blocks__sass"],
"@webpack-blocks/typescript": ["webpack-blocks__typescript"],
"@webpack-blocks/uglify": ["webpack-blocks__uglify"],
"@webpack-blocks/webpack": ["webpack-blocks__webpack"]
}
},
"files": [
"index.d.ts",
"webpack-blocks__uglify-tests.ts"
]
}

View File

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

View File

@ -0,0 +1,4 @@
import { createConfig } from 'webpack-blocks';
import uglify from '@webpack-blocks/uglify';
createConfig([uglify()]);

View File

@ -0,0 +1,44 @@
// Type definitions for @webpack-blocks/webpack 2.0
// Project: https://github.com/andywer/webpack-blocks/tree/master/packages/webpack
// Definitions by: Vladimir Grenaderov <https://github.com/VladimirGrenaderov>,
// Max Boguslavskiy <https://github.com/maxbogus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import {
Configuration,
Entry,
Options,
Output,
Plugin,
Resolve
} from 'webpack';
import { Context, Util, MatchOptions, ConfigSetter, InitialContext, Block, env, group, match, when } from '@webpack-blocks/core';
export { Context, Util, MatchOptions, ConfigSetter, InitialContext, Block, env, group, match, when } from '@webpack-blocks/core';
type PluginFunction = (compiler: any) => Plugin;
export interface ConstantOptions {
[constantName: string]: any;
}
export interface OptimizationOptions {
minimize?: boolean;
minimizer?: Plugin[] | PluginFunction;
}
export function createConfig(configSetters: Block | Block[]): Configuration;
export function setMode(mode: any): Block;
export function addPlugins(plugins: Plugin[]): Block;
export function customConfig(wpConfig: any): Configuration;
export function defineConstants(constants: ConstantOptions): Block;
export function setEnv(constants: ConstantOptions): any;
export function entryPoint(entry: string | string[] | Entry): Block;
export function performance(performanceBudget: Options.Performance): Block;
export function optimization(optimizationOptions: OptimizationOptions): Block;
export function resolve(config: Resolve): Block;
export function setContext(contextPath: string): Block;
export function setDevTool(devtool: string): Block;
export function setOutput(output?: string | Output): Block;
export function sourceMaps(devtool?: Options.Devtool): Block;

View File

@ -0,0 +1,36 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"esModuleInterop": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@webpack-blocks/assets": ["webpack-blocks__assets"],
"@webpack-blocks/babel": ["webpack-blocks__babel"],
"@webpack-blocks/core": ["webpack-blocks__core"],
"@webpack-blocks/dev-server": ["webpack-blocks__dev-server"],
"@webpack-blocks/extract-text": ["webpack-blocks__extract-text"],
"@webpack-blocks/postcss": ["webpack-blocks__postcss"],
"@webpack-blocks/sass": ["webpack-blocks__sass"],
"@webpack-blocks/typescript": ["webpack-blocks__typescript"],
"@webpack-blocks/uglify": ["webpack-blocks__uglify"],
"@webpack-blocks/webpack": ["webpack-blocks__webpack"]
}
},
"files": [
"index.d.ts",
"webpack-blocks__webpack-tests.ts"
]
}

View File

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

View File

@ -0,0 +1,11 @@
import { addPlugins, createConfig, entryPoint, env, setMode, setOutput, sourceMaps } from '@webpack-blocks/webpack';
import { css } from '@webpack-blocks/assets';
module.exports = createConfig([
setMode(process.env.NODE_ENV || 'development'),
entryPoint('./src/main.js'),
setOutput('./build/bundle.js'),
css(),
addPlugins([]),
env('development', [sourceMaps()]),
]);