webpack-config-jaid
Version:
Takes tiny input and returns a Webpack config in the way I personally like.
171 lines (166 loc) • 10 kB
TypeScript
declare function _default(): void;
declare module "webpack-config-jaid" {
export type TypeProvider = {
defines: {
[key: string]: string;
};
};
/**
* @property [packageRoot = require("app-root-path")()] - Directory of your Node project
* @property [development = process.env.NODE_ENV !== "production"] - Webpack mode ("development" or "production")
* @property [extra = {}] - Additional Webpack configuration
* @property [extraProduction = {}] - Additional Webpack configuration that only gets applied in development mode
* @property [extraDevelopment = {}] - Additional Webpack configuration that only gets applied in production mode
* @property [type = null] - The project type which will automatically add some configuration
* @property [include = ["readme.*","license.*"]] - Files (relative to project directory) that get copied to dist directory
* @property [publishimo = false] - Set to true to include publishimo-webpack-plugin, or set as object to add options for the plugin instance
* @property [documentation = false] - Set to true to include jsdoc-tsd-webpack-plugin, or set as object to add options for the plugin instance
* @property [nodeExternals = true] - If true, package dependencies will be loaded at runtime with require(), if false, they will be bundled
* @property [configOutput = Boolean(process.env.debugWebpack)] - If true, generated Webpack config and plugin info will be written to `dist/webpack-config-jaid`
* @property [clean = !options.development] - If false, no files and folders will be removed. If true, removed folders will be decided automatically. If an array is given, its paths will be removed. If an object is given, removed folders will be decided automatically and `options.clean` will be forwarded to the constructor of CleanWebpackPlugin.
* @property [title = null] - Project title
* @property [robots = false] - For type `webapp`: If `true`, output robots.txt
* @property [icon = null] - For type `webapp`: If typeof `string`, this will be used as path to png icon
* @property [domain] - For type `webapp`: If typeof `string`, this will be used as domain for CNAME
* @property [createCssFile = false] - For type `webapp`: If `true`, `extract-text-webpack-plugin` will be used to create a separate CSS file. If typeof `object`, this will be used as configuration for MiniCssExtractPlugin constructor.
* @property [optimizeCss = false] - For type `webapp`: If `true`, `optimize-css-assets-webpack-plugin` will be used to minify output CSS. If typeof `object`, this will be used as configuration for OptimizeCssAssetsPlugin constructor.
* @property [inlineSource = false] - For type `webapp`: If `true`, CSS and JavaScript content will be directly included into the HTML file
* @property [hashbang = null] - If typeof `string`, writes a hashbang to the top of the entry script. If it does not start with `!#`, it will be added automatically.
* @property [licenseFileName = "thirdPartyLicenses.txt"] - If typeof `string`, this will be the file where the third party license comments get extracted to.
* @property [terserOptions] - Additional options for `terser`
* @property [terserPluginOptions] - Additional options for `terser-webpack-plugin`
* @property [sourceFolder = path.join(packageRoot, "src")] - Folder where an `index.js` is placed in
* @property [outDir = path.join(packageRoot, "dist", "package", env)] - Output destination
* @property [backgroundColor = "000000"] - For type `webapp` if `options.icon` is defined: The webapp background color
* @property [themeColor = "04AAE3"] - For type `webapp` if `options.icon` is defined: The webapp theme color
* @property [publicPath] - Like `webpackConfig.publicPath`, but also applies to any plugin
* @property [excludeLocale = true] - Exclude i18n data for `moment`
* @property [twitterSiteHandle] - For type `webapp`: Twitter handle of the website for the output HTML's meta tags
* @property [twitterAuthorHandle] - For type `webapp`: Twitter handle of the author for the output HTML's meta tags
* @property [locale = en-US] - App language
* @property [sitemap = false] - For type `webapp`: If `true`, `sitemap-xml-webpack-plugin` will be used to output a `sitemap.xml`. If typeof `object`, this will be used as configuration for SitemapXmlWebpackPlugin constructor.
* @property [googleAnalyticsTrackingId] - For type `webapp`: If typeof `string`, will be used as the Google Analytics tracking id and resolves any occurence of `GOOGLE_ANALYTICS_TRACKING_ID` to given id
* @property [googleAnalyticsOnlyInProduction = true] - For type `webapp`: If `true`, option `googleAnalyticsTrackingId` will be ignored in any environment but `production`
* @property [friendlyErrors = false] - If `true`, includes `friendly-errors-webpack-plugin`
* @property [cepOptions = {}] - For type `adobeCep`: Additional option values that will be forwarded to `cep-webpack-plugin` constructor
* @property [banner = true] - If `true`, includes `pkg-banner-webpack-plugin`. If Object, this will be used as plugin options.
* @property [offline = false] - For type `webapp`: If `true`, includes `offline-plugin`. If Object, this will be used as plugin options.
* @property [pwa = false] - For type `webapp`: If `true`, includes `@expo/webpack-pwa-manifest-plugin`. If Object, this will be used as plugin options.
* @property [browserSync = Boolean(process.env.browserSync)] - If `true`, `browser-sync-webpack-plugin` will be included
*/
export type WebpackConfigJaidOptions = {
packageRoot?: string;
development?: boolean;
extra?: any;
extraProduction?: any;
extraDevelopment?: any;
type?: "cli" | "nodeLib" | "nodeClass" | "universalLib" | "universalClass" | "webapp" | "nodeScript" | "generatorCorePlugin" | "executable" | TypeProvider;
include?: any[];
publishimo?: boolean | any;
documentation?: boolean | any;
nodeExternals?: boolean;
configOutput?: boolean | string;
clean?: boolean | string[] | any;
title?: string;
robots?: boolean | any;
icon?: string;
domain?: string;
createCssFile?: boolean;
optimizeCss?: boolean;
inlineSource?: boolean;
hashbang?: string;
licenseFileName?: false | string;
terserOptions?: any;
terserPluginOptions?: any;
sourceFolder?: string;
outDir?: string;
backgroundColor?: string;
themeColor?: string;
publicPath?: string;
excludeLocale?: boolean;
appDescription?: string;
twitterSiteHandle?: string;
twitterAuthorHandle?: string;
locale?: string;
sitemap?: boolean | any;
googleAnalyticsTrackingId?: string;
googleAnalyticsOnlyInProduction?: boolean;
friendlyErrors?: boolean;
cepOptions?: any;
banner?: any | boolean;
offline?: any | boolean;
pwa?: any | boolean;
browserSync?: boolean;
};
/**
* Creates Webpack config based on given options
* @param [options] - Given options
* @returns Webpack configuration object
*/
export default function(options?: WebpackConfigJaidOptions): any;
/**
* Creates Webpack config based on given options, uses type "cli"
* @param [options] - Given options
* @returns Webpack configuration object
*/
export function configureCli(options?: WebpackConfigJaidOptions): any;
/**
* Creates Webpack config based on given options, uses type "nodeLib"
* @param [options] - Given options
* @returns Webpack configuration object
*/
export function configureNodeLib(options?: WebpackConfigJaidOptions): any;
/**
* Creates Webpack config based on given options, uses type "nodeClass"
* @param [options] - Given options
* @returns Webpack configuration object
*/
export function configureNodeClass(options?: WebpackConfigJaidOptions): any;
/**
* Creates Webpack config based on given options, uses type "universalLib"
* @param [options] - Given options
* @returns Webpack configuration object
*/
export function configureUniversalLib(options?: WebpackConfigJaidOptions): any;
/**
* Creates Webpack config based on given options, uses type "universalClass"
* @param [options] - Given options
* @returns Webpack configuration object
*/
export function configureUniversalClass(options?: WebpackConfigJaidOptions): any;
/**
* Creates Webpack config based on given options, uses type "webapp"
* @param [options] - Given options
* @returns Webpack configuration object
*/
export function configureWebapp(options?: WebpackConfigJaidOptions): any;
/**
* Creates Webpack config based on given options, uses type "nodeScript"
* @param [options] - Given options
* @returns Webpack configuration object
*/
export function configureNodeScript(options?: WebpackConfigJaidOptions): any;
/**
* Creates Webpack config based on given options, uses type "generatorCorePlugin"
* @param [options] - Given options
* @returns Webpack configuration object
*/
export function configureGeneratorCorePlugin(options?: WebpackConfigJaidOptions): any;
/**
* Creates Webpack config based on given options, uses type "executable"
* @param [options] - Given options
* @returns Webpack configuration object
*/
export function configureExecutable(options?: WebpackConfigJaidOptions): any;
}
declare type GetDefaultOptionsContext = {
env: string;
};
declare type ProcessOptionsContext = {
env: string;
};
declare type GetWebpackConfigContext = {
entryFolder: string;
pkg: any;
};
declare function _default(): void;