mirror of https://github.com/webpack/webpack.git
Compare commits
8 Commits
ec78a303e6
...
010b90de2a
Author | SHA1 | Date |
---|---|---|
|
010b90de2a | |
|
e9b5f669c9 | |
|
37ff2904cb | |
|
7d37ce4a0e | |
|
bbcf095dd9 | |
|
3df51cb887 | |
|
ea68eada62 | |
|
e62546989c |
|
@ -315,8 +315,7 @@
|
||||||
"spacek",
|
"spacek",
|
||||||
"thelarkinn",
|
"thelarkinn",
|
||||||
"behaviour",
|
"behaviour",
|
||||||
"WHATWG",
|
"WHATWG"
|
||||||
"systemvars"
|
|
||||||
],
|
],
|
||||||
"ignoreRegExpList": [
|
"ignoreRegExpList": [
|
||||||
"/Author.+/",
|
"/Author.+/",
|
||||||
|
|
|
@ -50,18 +50,7 @@ export type DevTool = (false | "eval") | string;
|
||||||
/**
|
/**
|
||||||
* Enable and configure the Dotenv plugin to load environment variables from .env files.
|
* Enable and configure the Dotenv plugin to load environment variables from .env files.
|
||||||
*/
|
*/
|
||||||
export type Dotenv =
|
export type Dotenv = boolean | DotenvPluginOptions;
|
||||||
| boolean
|
|
||||||
| {
|
|
||||||
/**
|
|
||||||
* The directory from which .env files are loaded. Defaults to the webpack context. Loads .env, .env.local, .env.[mode], .env.[mode].local in order.
|
|
||||||
*/
|
|
||||||
envDir?: string;
|
|
||||||
/**
|
|
||||||
* Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.
|
|
||||||
*/
|
|
||||||
prefixes?: string[] | string;
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* The entry point(s) of the compilation.
|
* The entry point(s) of the compilation.
|
||||||
*/
|
*/
|
||||||
|
@ -1127,6 +1116,19 @@ export interface FileCacheOptions {
|
||||||
*/
|
*/
|
||||||
version?: string;
|
version?: string;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Options for Dotenv plugin.
|
||||||
|
*/
|
||||||
|
export interface DotenvPluginOptions {
|
||||||
|
/**
|
||||||
|
* The directory from which .env files are loaded. Can be an absolute path, or a path relative to the project root. false will disable the .env file loading.
|
||||||
|
*/
|
||||||
|
dir?: boolean | string;
|
||||||
|
/**
|
||||||
|
* Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.
|
||||||
|
*/
|
||||||
|
prefix?: string[] | string;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Multiple entry bundles are created. The key is the entry name. The value can be a string, an array or an entry description object.
|
* Multiple entry bundles are created. The key is the entry name. The value can be a string, an array or an entry description object.
|
||||||
*/
|
*/
|
||||||
|
@ -3080,19 +3082,6 @@ export interface CssParserOptions {
|
||||||
*/
|
*/
|
||||||
url?: CssParserUrl;
|
url?: CssParserUrl;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Options for Dotenv plugin.
|
|
||||||
*/
|
|
||||||
export interface DotenvPluginOptions {
|
|
||||||
/**
|
|
||||||
* The directory from which .env files are loaded. Defaults to the webpack context. Loads .env, .env.local, .env.[mode], .env.[mode].local in order.
|
|
||||||
*/
|
|
||||||
envDir?: string;
|
|
||||||
/**
|
|
||||||
* Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.
|
|
||||||
*/
|
|
||||||
prefixes?: string[] | string;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* No generator options are supported for this module type.
|
* No generator options are supported for this module type.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
/*
|
|
||||||
* This file was automatically generated.
|
|
||||||
* DO NOT MODIFY BY HAND.
|
|
||||||
* Run `yarn fix:special` to update
|
|
||||||
*/
|
|
||||||
|
|
||||||
export interface DotenvPluginOptions {
|
|
||||||
/**
|
|
||||||
* Whether to allow empty strings in safe mode. If false, will throw an error if any env variables are empty (but only if safe mode is enabled).
|
|
||||||
*/
|
|
||||||
allowEmptyValues?: boolean;
|
|
||||||
/**
|
|
||||||
* Adds support for dotenv-defaults. If set to true, uses ./.env.defaults. If a string, uses that location for a defaults file.
|
|
||||||
*/
|
|
||||||
defaults?: boolean | string;
|
|
||||||
/**
|
|
||||||
* Allows your variables to be "expanded" for reusability within your .env file.
|
|
||||||
*/
|
|
||||||
expand?: boolean;
|
|
||||||
/**
|
|
||||||
* The path to your environment variables. This same path applies to the .env.example and .env.defaults files.
|
|
||||||
*/
|
|
||||||
path?: string;
|
|
||||||
/**
|
|
||||||
* The prefix to use before the name of your env variables.
|
|
||||||
*/
|
|
||||||
prefix?: string;
|
|
||||||
/**
|
|
||||||
* If true, load '.env.example' to verify the '.env' variables are all set. Can also be a string to a different file.
|
|
||||||
*/
|
|
||||||
safe?: boolean | string;
|
|
||||||
/**
|
|
||||||
* Set to true if you would rather load all system variables as well (useful for CI purposes).
|
|
||||||
*/
|
|
||||||
systemvars?: boolean;
|
|
||||||
}
|
|
|
@ -12,9 +12,10 @@ const { join } = require("./util/fs");
|
||||||
/** @typedef {import("./Compiler")} Compiler */
|
/** @typedef {import("./Compiler")} Compiler */
|
||||||
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
||||||
|
|
||||||
|
/** @type {DotenvPluginOptions} */
|
||||||
const DEFAULT_OPTIONS = {
|
const DEFAULT_OPTIONS = {
|
||||||
prefixes: "WEBPACK_",
|
prefix: "WEBPACK_",
|
||||||
envDir: true
|
dir: true
|
||||||
};
|
};
|
||||||
|
|
||||||
// Regex for parsing .env files
|
// Regex for parsing .env files
|
||||||
|
@ -206,18 +207,18 @@ function expand(options) {
|
||||||
/**
|
/**
|
||||||
* Resolve and validate env prefixes
|
* Resolve and validate env prefixes
|
||||||
* Similar to Vite's resolveEnvPrefix
|
* Similar to Vite's resolveEnvPrefix
|
||||||
* @param {string | string[] | undefined} rawPrefixes raw prefixes option
|
* @param {string | string[] | undefined} rawPrefix raw prefix option
|
||||||
* @returns {string[]} normalized prefixes array
|
* @returns {string[]} normalized prefixes array
|
||||||
*/
|
*/
|
||||||
const resolveEnvPrefix = (rawPrefixes) => {
|
const resolveEnvPrefix = (rawPrefix) => {
|
||||||
const prefixes = Array.isArray(rawPrefixes)
|
const prefixes = Array.isArray(rawPrefix)
|
||||||
? rawPrefixes
|
? rawPrefix
|
||||||
: [rawPrefixes || "WEBPACK_"];
|
: [rawPrefix || "WEBPACK_"];
|
||||||
|
|
||||||
// Check for empty prefix (security issue like Vite does)
|
// Check for empty prefix (security issue like Vite does)
|
||||||
if (prefixes.includes("")) {
|
if (prefixes.includes("")) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"prefixes option contains value '', which could lead to unexpected exposure of sensitive information."
|
"prefix option contains value '', which could lead to unexpected exposure of sensitive information."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,18 +229,18 @@ const resolveEnvPrefix = (rawPrefixes) => {
|
||||||
* Get list of env files to load based on mode
|
* Get list of env files to load based on mode
|
||||||
* Similar to Vite's getEnvFilesForMode
|
* Similar to Vite's getEnvFilesForMode
|
||||||
* @param {InputFileSystem} inputFileSystem the input file system
|
* @param {InputFileSystem} inputFileSystem the input file system
|
||||||
* @param {string} envDir the directory containing .env files
|
* @param {string} dir the directory containing .env files
|
||||||
* @param {string | undefined} mode the mode (e.g., 'production', 'development')
|
* @param {string | undefined} mode the mode (e.g., 'production', 'development')
|
||||||
* @returns {string[]} array of file paths to load
|
* @returns {string[]} array of file paths to load
|
||||||
*/
|
*/
|
||||||
const getEnvFilesForMode = (inputFileSystem, envDir, mode) => {
|
const getEnvFilesForMode = (inputFileSystem, dir, mode) => {
|
||||||
if (envDir) {
|
if (dir) {
|
||||||
return [
|
return [
|
||||||
/** default file */ ".env",
|
/** default file */ ".env",
|
||||||
/** local file */ ".env.local",
|
/** local file */ ".env.local",
|
||||||
/** mode file */ `.env.${mode}`,
|
/** mode file */ `.env.${mode}`,
|
||||||
/** mode local file */ `.env.${mode}.local`
|
/** mode local file */ `.env.${mode}.local`
|
||||||
].map((file) => join(inputFileSystem, envDir, file));
|
].map((file) => join(inputFileSystem, dir, file));
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
|
@ -321,30 +322,33 @@ class DotenvPlugin {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
loadEnv(fs, mode, context, callback) {
|
loadEnv(fs, mode, context, callback) {
|
||||||
const { envDir: rawEnvDir, prefixes: rawPrefixes } =
|
const { dir: rawDir, prefix: rawPrefix } =
|
||||||
/** @type {DotenvPluginOptions} */ (this.config);
|
/** @type {DotenvPluginOptions} */ (this.config);
|
||||||
|
|
||||||
let prefixes;
|
let prefixes;
|
||||||
try {
|
try {
|
||||||
prefixes = resolveEnvPrefix(rawPrefixes);
|
prefixes = resolveEnvPrefix(rawPrefix);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return callback(/** @type {Error} */ (err));
|
return callback(/** @type {Error} */ (err));
|
||||||
}
|
}
|
||||||
|
|
||||||
const getEnvDir = () => {
|
const getDir = () => {
|
||||||
if (typeof rawEnvDir === "string") {
|
if (typeof rawDir === "string") {
|
||||||
return join(fs, context, rawEnvDir);
|
return join(fs, context, rawDir);
|
||||||
}
|
}
|
||||||
if (rawEnvDir === true) {
|
if (rawDir === true) {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
if (rawDir === false) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
const envDir = getEnvDir();
|
const dir = getDir();
|
||||||
|
|
||||||
// Get env files to load
|
// Get env files to load
|
||||||
const envFiles = getEnvFilesForMode(fs, envDir, mode);
|
const envFiles = getEnvFilesForMode(fs, dir, mode);
|
||||||
/** @type {string[]} */
|
/** @type {string[]} */
|
||||||
const fileDependencies = [];
|
const fileDependencies = [];
|
||||||
|
|
||||||
|
|
|
@ -178,9 +178,7 @@ const getNormalizedWebpackOptions = (config) => ({
|
||||||
return { ...devServer };
|
return { ...devServer };
|
||||||
}),
|
}),
|
||||||
devtool: config.devtool,
|
devtool: config.devtool,
|
||||||
dotenv: optionalNestedConfig(config.dotenv, (dotenv) =>
|
dotenv: config.dotenv,
|
||||||
dotenv === true ? {} : dotenv
|
|
||||||
),
|
|
||||||
entry:
|
entry:
|
||||||
config.entry === undefined
|
config.entry === undefined
|
||||||
? { main: {} }
|
? { main: {} }
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -640,8 +640,7 @@
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/definitions/DotenvPluginOptions",
|
"$ref": "#/definitions/DotenvPluginOptions"
|
||||||
"description": "Options for Dotenv plugin."
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -650,17 +649,25 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
"envDir": {
|
"dir": {
|
||||||
"description": "The directory from which .env files are loaded. Defaults to the webpack context. Loads .env, .env.local, .env.[mode], .env.[mode].local in order.",
|
"description": "The directory from which .env files are loaded. Can be an absolute path, or a path relative to the project root. false will disable the .env file loading.",
|
||||||
"type": "string",
|
"anyOf": [
|
||||||
"minLength": 1
|
{
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"prefixes": {
|
"prefix": {
|
||||||
"description": "Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.",
|
"description": "Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.",
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
"description": "A prefix that environment variables must start with to be exposed.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1
|
"minLength": 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,7 @@ describe("snapshots", () => {
|
||||||
"dependencies": undefined,
|
"dependencies": undefined,
|
||||||
"devServer": undefined,
|
"devServer": undefined,
|
||||||
"devtool": false,
|
"devtool": false,
|
||||||
|
"dotenv": undefined,
|
||||||
"entry": Object {
|
"entry": Object {
|
||||||
"main": Object {
|
"main": Object {
|
||||||
"import": Array [
|
"import": Array [
|
||||||
|
|
|
@ -79,7 +79,7 @@ describe("Validation", () => {
|
||||||
expect(msg).toMatchInlineSnapshot(`
|
expect(msg).toMatchInlineSnapshot(`
|
||||||
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
||||||
- configuration should be an object:
|
- configuration should be an object:
|
||||||
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, dotenv?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
||||||
-> Options object as provided by the user."
|
-> Options object as provided by the user."
|
||||||
`)
|
`)
|
||||||
);
|
);
|
||||||
|
@ -88,7 +88,7 @@ describe("Validation", () => {
|
||||||
expect(msg).toMatchInlineSnapshot(`
|
expect(msg).toMatchInlineSnapshot(`
|
||||||
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
||||||
- configuration should be an object:
|
- configuration should be an object:
|
||||||
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, dotenv?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
||||||
-> Options object as provided by the user."
|
-> Options object as provided by the user."
|
||||||
`)
|
`)
|
||||||
);
|
);
|
||||||
|
@ -251,7 +251,7 @@ describe("Validation", () => {
|
||||||
expect(msg).toMatchInlineSnapshot(`
|
expect(msg).toMatchInlineSnapshot(`
|
||||||
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
||||||
- configuration has an unknown property 'postcss'. These properties are valid:
|
- configuration has an unknown property 'postcss'. These properties are valid:
|
||||||
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, dotenv?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
||||||
-> Options object as provided by the user.
|
-> Options object as provided by the user.
|
||||||
For typos: please correct them.
|
For typos: please correct them.
|
||||||
For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration.
|
For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration.
|
||||||
|
@ -494,7 +494,7 @@ describe("Validation", () => {
|
||||||
expect(msg).toMatchInlineSnapshot(`
|
expect(msg).toMatchInlineSnapshot(`
|
||||||
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
||||||
- configuration has an unknown property 'debug'. These properties are valid:
|
- configuration has an unknown property 'debug'. These properties are valid:
|
||||||
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, dotenv?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
||||||
-> Options object as provided by the user.
|
-> Options object as provided by the user.
|
||||||
The 'debug' property was removed in webpack 2.0.0.
|
The 'debug' property was removed in webpack 2.0.0.
|
||||||
Loaders should be updated to allow passing this option via loader options in module.rules.
|
Loaders should be updated to allow passing this option via loader options in module.rules.
|
||||||
|
@ -542,7 +542,7 @@ describe("Validation", () => {
|
||||||
expect(msg).toMatchInlineSnapshot(`
|
expect(msg).toMatchInlineSnapshot(`
|
||||||
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
||||||
- configuration[1] should be an object:
|
- configuration[1] should be an object:
|
||||||
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, dotenv?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
||||||
-> Options object as provided by the user."
|
-> Options object as provided by the user."
|
||||||
`)
|
`)
|
||||||
);
|
);
|
||||||
|
@ -664,7 +664,7 @@ describe("Validation", () => {
|
||||||
expect(msg).toMatchInlineSnapshot(`
|
expect(msg).toMatchInlineSnapshot(`
|
||||||
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
||||||
- configuration has an unknown property 'rules'. These properties are valid:
|
- configuration has an unknown property 'rules'. These properties are valid:
|
||||||
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, dotenv?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
||||||
-> Options object as provided by the user.
|
-> Options object as provided by the user.
|
||||||
Did you mean module.rules?"
|
Did you mean module.rules?"
|
||||||
`)
|
`)
|
||||||
|
@ -679,7 +679,7 @@ describe("Validation", () => {
|
||||||
expect(msg).toMatchInlineSnapshot(`
|
expect(msg).toMatchInlineSnapshot(`
|
||||||
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
||||||
- configuration has an unknown property 'splitChunks'. These properties are valid:
|
- configuration has an unknown property 'splitChunks'. These properties are valid:
|
||||||
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, dotenv?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
||||||
-> Options object as provided by the user.
|
-> Options object as provided by the user.
|
||||||
Did you mean optimization.splitChunks?"
|
Did you mean optimization.splitChunks?"
|
||||||
`)
|
`)
|
||||||
|
@ -694,7 +694,7 @@ describe("Validation", () => {
|
||||||
expect(msg).toMatchInlineSnapshot(`
|
expect(msg).toMatchInlineSnapshot(`
|
||||||
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
|
||||||
- configuration has an unknown property 'noParse'. These properties are valid:
|
- configuration has an unknown property 'noParse'. These properties are valid:
|
||||||
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, dotenv?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
|
||||||
-> Options object as provided by the user.
|
-> Options object as provided by the user.
|
||||||
Did you mean module.noParse?"
|
Did you mean module.noParse?"
|
||||||
`)
|
`)
|
||||||
|
|
|
@ -478,42 +478,48 @@ Object {
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"simpleType": "boolean",
|
"simpleType": "boolean",
|
||||||
},
|
},
|
||||||
"dotenv-env-dir": Object {
|
"dotenv-dir": Object {
|
||||||
"configs": Array [
|
"configs": Array [
|
||||||
Object {
|
Object {
|
||||||
"description": "The directory from which .env files are loaded. Defaults to the webpack context. Loads .env, .env.local, .env.[mode], .env.[mode].local in order.",
|
"description": "The directory from which .env files are loaded. Can be an absolute path, or a path relative to the project root. false will disable the .env file loading.",
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"path": "dotenv.envDir",
|
"path": "dotenv.dir",
|
||||||
|
"type": "boolean",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"description": "The directory from which .env files are loaded. Can be an absolute path, or a path relative to the project root. false will disable the .env file loading.",
|
||||||
|
"multiple": false,
|
||||||
|
"path": "dotenv.dir",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"description": "The directory from which .env files are loaded. Defaults to the webpack context. Loads .env, .env.local, .env.[mode], .env.[mode].local in order.",
|
"description": "The directory from which .env files are loaded. Can be an absolute path, or a path relative to the project root. false will disable the .env file loading.",
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"simpleType": "string",
|
"simpleType": "string",
|
||||||
},
|
},
|
||||||
"dotenv-prefixes": Object {
|
"dotenv-prefix": Object {
|
||||||
"configs": Array [
|
"configs": Array [
|
||||||
Object {
|
Object {
|
||||||
"description": "Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.",
|
"description": "A prefix that environment variables must start with to be exposed.",
|
||||||
"multiple": true,
|
"multiple": true,
|
||||||
"path": "dotenv.prefixes[]",
|
"path": "dotenv.prefix[]",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"description": "Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.",
|
"description": "A prefix that environment variables must start with to be exposed.",
|
||||||
"multiple": true,
|
"multiple": true,
|
||||||
"simpleType": "string",
|
"simpleType": "string",
|
||||||
},
|
},
|
||||||
"dotenv-prefixes-reset": Object {
|
"dotenv-prefix-reset": Object {
|
||||||
"configs": Array [
|
"configs": Array [
|
||||||
Object {
|
Object {
|
||||||
"description": "Clear all items provided in 'dotenv.prefixes' configuration. Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.",
|
"description": "Clear all items provided in 'dotenv.prefix' configuration. Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.",
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"path": "dotenv.prefixes",
|
"path": "dotenv.prefix",
|
||||||
"type": "reset",
|
"type": "reset",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"description": "Clear all items provided in 'dotenv.prefixes' configuration. Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.",
|
"description": "Clear all items provided in 'dotenv.prefix' configuration. Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.",
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"simpleType": "boolean",
|
"simpleType": "boolean",
|
||||||
},
|
},
|
||||||
|
|
|
@ -671,4 +671,4 @@ Before we started using OpenCollective, donations were made anonymously. Now tha
|
||||||
[dependency-review-url]: https://github.com/webpack/webpack/actions/workflows/dependency-review.yml
|
[dependency-review-url]: https://github.com/webpack/webpack/actions/workflows/dependency-review.yml
|
||||||
[dependency-review]: https://github.com/webpack/webpack/actions/workflows/dependency-review.yml/badge.svg
|
[dependency-review]: https://github.com/webpack/webpack/actions/workflows/dependency-review.yml/badge.svg
|
||||||
[cover]: https://codecov.io/gh/webpack/webpack/graph/badge.svg?token=mDP3mQJNnn
|
[cover]: https://codecov.io/gh/webpack/webpack/graph/badge.svg?token=mDP3mQJNnn
|
||||||
[cover-url]: https://codecov.io/gh/webpack/webpack
|
[cover-url]: https://codecov.io/gh/webpack/webpack
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
it("should load from custom envDir", () => {
|
it("should load from custom dir", () => {
|
||||||
expect(process.env.WEBPACK_FROM_ENVS).toBe("loaded-from-envs-dir");
|
expect(process.env.WEBPACK_FROM_ENVS).toBe("loaded-from-envs-dir");
|
||||||
expect(process.env.WEBPACK_API_URL).toBe("https://custom.example.com");
|
expect(process.env.WEBPACK_API_URL).toBe("https://custom.example.com");
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
it("should not load any .env files when dir is false", () => {
|
||||||
|
// When dir: false, no .env files should be loaded
|
||||||
|
// Only environment variables that were already set in process.env should be available
|
||||||
|
// and only those with WEBPACK_ prefix should be exposed
|
||||||
|
|
||||||
|
// These should be undefined since no .env files are loaded
|
||||||
|
expect(typeof process.env.WEBPACK_API_URL).toBe("undefined");
|
||||||
|
expect(typeof process.env.WEBPACK_MODE).toBe("undefined");
|
||||||
|
expect(typeof process.env.SECRET_KEY).toBe("undefined");
|
||||||
|
expect(typeof process.env.PRIVATE_VAR).toBe("undefined");
|
||||||
|
|
||||||
|
// Only pre-existing process.env variables with WEBPACK_ prefix should be available
|
||||||
|
// (if any were set before webpack runs)
|
||||||
|
});
|
|
@ -16,13 +16,13 @@ module.exports = [
|
||||||
entry: "./expand.js",
|
entry: "./expand.js",
|
||||||
dotenv: true
|
dotenv: true
|
||||||
},
|
},
|
||||||
// Test 3: Custom envDir - load from different directory
|
// Test 3: Custom dir - load from different directory
|
||||||
{
|
{
|
||||||
name: "custom-envdir",
|
name: "custom-dir",
|
||||||
mode: "development",
|
mode: "development",
|
||||||
entry: "./custom-envdir.js",
|
entry: "./custom-envdir.js",
|
||||||
dotenv: {
|
dotenv: {
|
||||||
envDir: "./envs"
|
dir: "./envs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Test 4: Custom prefixes - multiple prefixes
|
// Test 4: Custom prefixes - multiple prefixes
|
||||||
|
@ -31,8 +31,8 @@ module.exports = [
|
||||||
mode: "development",
|
mode: "development",
|
||||||
entry: "./custom-prefixes.js",
|
entry: "./custom-prefixes.js",
|
||||||
dotenv: {
|
dotenv: {
|
||||||
envDir: "./prefixes-env",
|
dir: "./prefixes-env",
|
||||||
prefixes: ["APP_", "CONFIG_"]
|
prefix: ["APP_", "CONFIG_"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Test 5: Mode-specific - .env.[mode] overrides
|
// Test 5: Mode-specific - .env.[mode] overrides
|
||||||
|
@ -41,5 +41,14 @@ module.exports = [
|
||||||
mode: "production",
|
mode: "production",
|
||||||
entry: "./mode-specific.js",
|
entry: "./mode-specific.js",
|
||||||
dotenv: true
|
dotenv: true
|
||||||
|
},
|
||||||
|
// Test 6: Disabled dir - dir: false disables .env file loading
|
||||||
|
{
|
||||||
|
name: "disabled-dir",
|
||||||
|
mode: "development",
|
||||||
|
entry: "./disabled-dir.js",
|
||||||
|
dotenv: {
|
||||||
|
dir: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -24,7 +24,7 @@ import {
|
||||||
ClassBody,
|
ClassBody,
|
||||||
ClassDeclaration,
|
ClassDeclaration,
|
||||||
ClassExpression,
|
ClassExpression,
|
||||||
Comment,
|
Comment as CommentImport,
|
||||||
ConditionalExpression,
|
ConditionalExpression,
|
||||||
ContinueStatement,
|
ContinueStatement,
|
||||||
DebuggerStatement,
|
DebuggerStatement,
|
||||||
|
@ -99,9 +99,11 @@ import {
|
||||||
} from "inspector";
|
} from "inspector";
|
||||||
import { JSONSchema4, JSONSchema6, JSONSchema7 } from "json-schema";
|
import { JSONSchema4, JSONSchema6, JSONSchema7 } from "json-schema";
|
||||||
import { ListenOptions } from "net";
|
import { ListenOptions } from "net";
|
||||||
import { validate as validateFunction } from "schema-utils";
|
import {
|
||||||
|
ValidationErrorConfiguration,
|
||||||
|
validate as validateFunction
|
||||||
|
} from "schema-utils";
|
||||||
import { default as ValidationError } from "schema-utils/declarations/ValidationError";
|
import { default as ValidationError } from "schema-utils/declarations/ValidationError";
|
||||||
import { ValidationErrorConfiguration } from "schema-utils/declarations/validate";
|
|
||||||
import {
|
import {
|
||||||
AsArray,
|
AsArray,
|
||||||
AsyncParallelHook,
|
AsyncParallelHook,
|
||||||
|
@ -114,7 +116,8 @@ import {
|
||||||
SyncBailHook,
|
SyncBailHook,
|
||||||
SyncHook,
|
SyncHook,
|
||||||
SyncWaterfallHook,
|
SyncWaterfallHook,
|
||||||
TapOptions
|
TapOptions,
|
||||||
|
TypedHookMap
|
||||||
} from "tapable";
|
} from "tapable";
|
||||||
import { SecureContextOptions, TlsOptions } from "tls";
|
import { SecureContextOptions, TlsOptions } from "tls";
|
||||||
import { URL } from "url";
|
import { URL } from "url";
|
||||||
|
@ -297,6 +300,14 @@ declare interface Asset {
|
||||||
*/
|
*/
|
||||||
info: AssetInfo;
|
info: AssetInfo;
|
||||||
}
|
}
|
||||||
|
declare abstract class AssetBytesGenerator extends Generator {
|
||||||
|
generateError(
|
||||||
|
error: Error,
|
||||||
|
module: NormalModule,
|
||||||
|
generateContext: GenerateContext
|
||||||
|
): null | Source;
|
||||||
|
}
|
||||||
|
declare abstract class AssetBytesParser extends ParserClass {}
|
||||||
declare interface AssetDependencyMeta {
|
declare interface AssetDependencyMeta {
|
||||||
sourceType: "css-url";
|
sourceType: "css-url";
|
||||||
}
|
}
|
||||||
|
@ -311,6 +322,25 @@ type AssetFilterItemTypes =
|
||||||
| string
|
| string
|
||||||
| RegExp
|
| RegExp
|
||||||
| ((name: string, asset: StatsAsset) => boolean);
|
| ((name: string, asset: StatsAsset) => boolean);
|
||||||
|
declare abstract class AssetGenerator extends Generator {
|
||||||
|
dataUrlOptions?:
|
||||||
|
| AssetGeneratorDataUrlOptions
|
||||||
|
| ((
|
||||||
|
source: string | Buffer,
|
||||||
|
context: { filename: string; module: Module }
|
||||||
|
) => string);
|
||||||
|
filename?: string | ((pathData: PathData, assetInfo?: AssetInfo) => string);
|
||||||
|
publicPath?: string | ((pathData: PathData, assetInfo?: AssetInfo) => string);
|
||||||
|
outputPath?: string | ((pathData: PathData, assetInfo?: AssetInfo) => string);
|
||||||
|
emit?: boolean;
|
||||||
|
getMimeType(module: NormalModule): string;
|
||||||
|
generateDataUri(module: NormalModule): string;
|
||||||
|
generateError(
|
||||||
|
error: Error,
|
||||||
|
module: NormalModule,
|
||||||
|
generateContext: GenerateContext
|
||||||
|
): null | Source;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options object for data url generation.
|
* Options object for data url generation.
|
||||||
|
@ -349,6 +379,15 @@ declare interface AssetInlineGeneratorOptions {
|
||||||
context: { filename: string; module: Module }
|
context: { filename: string; module: Module }
|
||||||
) => string);
|
) => string);
|
||||||
}
|
}
|
||||||
|
declare abstract class AssetParser extends ParserClass {
|
||||||
|
dataUrlCondition?:
|
||||||
|
| boolean
|
||||||
|
| AssetParserDataUrlOptions
|
||||||
|
| ((
|
||||||
|
source: string | Buffer,
|
||||||
|
context: { filename: string; module: Module }
|
||||||
|
) => boolean);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options object for DataUrl condition.
|
* Options object for DataUrl condition.
|
||||||
|
@ -404,6 +443,14 @@ declare interface AssetResourceGeneratorOptions {
|
||||||
*/
|
*/
|
||||||
publicPath?: string | ((pathData: PathData, assetInfo?: AssetInfo) => string);
|
publicPath?: string | ((pathData: PathData, assetInfo?: AssetInfo) => string);
|
||||||
}
|
}
|
||||||
|
declare abstract class AssetSourceGenerator extends Generator {
|
||||||
|
generateError(
|
||||||
|
error: Error,
|
||||||
|
module: NormalModule,
|
||||||
|
generateContext: GenerateContext
|
||||||
|
): null | Source;
|
||||||
|
}
|
||||||
|
declare abstract class AssetSourceParser extends ParserClass {}
|
||||||
declare class AsyncDependenciesBlock extends DependenciesBlock {
|
declare class AsyncDependenciesBlock extends DependenciesBlock {
|
||||||
constructor(
|
constructor(
|
||||||
groupOptions:
|
groupOptions:
|
||||||
|
@ -473,6 +520,7 @@ declare interface AsyncWebAssemblyModulesPluginOptions {
|
||||||
*/
|
*/
|
||||||
mangleImports?: boolean;
|
mangleImports?: boolean;
|
||||||
}
|
}
|
||||||
|
declare abstract class AsyncWebAssemblyParser extends ParserClass {}
|
||||||
declare class AutomaticPrefetchPlugin {
|
declare class AutomaticPrefetchPlugin {
|
||||||
constructor();
|
constructor();
|
||||||
|
|
||||||
|
@ -2044,6 +2092,11 @@ declare interface ColorsOptions {
|
||||||
*/
|
*/
|
||||||
useColor?: boolean;
|
useColor?: boolean;
|
||||||
}
|
}
|
||||||
|
declare interface CommentCssParser {
|
||||||
|
value: string;
|
||||||
|
range: [number, number];
|
||||||
|
loc: { start: Position; end: Position };
|
||||||
|
}
|
||||||
declare interface CommonJsImportSettings {
|
declare interface CommonJsImportSettings {
|
||||||
name?: string;
|
name?: string;
|
||||||
context: string;
|
context: string;
|
||||||
|
@ -2950,18 +3003,7 @@ declare interface Configuration {
|
||||||
/**
|
/**
|
||||||
* Enable and configure the Dotenv plugin to load environment variables from .env files.
|
* Enable and configure the Dotenv plugin to load environment variables from .env files.
|
||||||
*/
|
*/
|
||||||
dotenv?:
|
dotenv?: boolean | DotenvPluginOptions;
|
||||||
| boolean
|
|
||||||
| {
|
|
||||||
/**
|
|
||||||
* The directory from which .env files are loaded. Defaults to the webpack context. Loads .env, .env.local, .env.[mode], .env.[mode].local in order.
|
|
||||||
*/
|
|
||||||
envDir?: string;
|
|
||||||
/**
|
|
||||||
* Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.
|
|
||||||
*/
|
|
||||||
prefixes?: string | string[];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The entry point(s) of the compilation.
|
* The entry point(s) of the compilation.
|
||||||
|
@ -3574,6 +3616,23 @@ declare interface CssData {
|
||||||
*/
|
*/
|
||||||
exports: Map<string, string>;
|
exports: Map<string, string>;
|
||||||
}
|
}
|
||||||
|
declare abstract class CssGenerator extends Generator {
|
||||||
|
convention?:
|
||||||
|
| "as-is"
|
||||||
|
| "camel-case"
|
||||||
|
| "camel-case-only"
|
||||||
|
| "dashes"
|
||||||
|
| "dashes-only"
|
||||||
|
| ((name: string) => string);
|
||||||
|
localIdentName?: string;
|
||||||
|
exportsOnly?: boolean;
|
||||||
|
esModule?: boolean;
|
||||||
|
generateError(
|
||||||
|
error: Error,
|
||||||
|
module: NormalModule,
|
||||||
|
generateContext: GenerateContext
|
||||||
|
): null | Source;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generator options for css modules.
|
* Generator options for css modules.
|
||||||
|
@ -3769,6 +3828,19 @@ declare class CssModulesPlugin {
|
||||||
): TemplatePath;
|
): TemplatePath;
|
||||||
static chunkHasCss(chunk: Chunk, chunkGraph: ChunkGraph): boolean;
|
static chunkHasCss(chunk: Chunk, chunkGraph: ChunkGraph): boolean;
|
||||||
}
|
}
|
||||||
|
declare abstract class CssParser extends ParserClass {
|
||||||
|
defaultMode: "global" | "auto" | "pure" | "local";
|
||||||
|
import: boolean;
|
||||||
|
url: boolean;
|
||||||
|
namedExports: boolean;
|
||||||
|
comments?: CommentCssParser[];
|
||||||
|
magicCommentContext: Context;
|
||||||
|
getComments(range: [number, number]): CommentCssParser[];
|
||||||
|
parseCommentOptions(range: [number, number]): {
|
||||||
|
options: null | Record<string, any>;
|
||||||
|
errors: null | (Error & { comment: CommentCssParser })[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parser options for css modules.
|
* Parser options for css modules.
|
||||||
|
@ -4356,13 +4428,13 @@ declare class DotenvPlugin {
|
||||||
constructor(options?: DotenvPluginOptions);
|
constructor(options?: DotenvPluginOptions);
|
||||||
config: {
|
config: {
|
||||||
/**
|
/**
|
||||||
* The directory from which .env files are loaded. Defaults to the webpack context. Loads .env, .env.local, .env.[mode], .env.[mode].local in order.
|
* The directory from which .env files are loaded. Can be an absolute path, or a path relative to the project root. false will disable the .env file loading.
|
||||||
*/
|
*/
|
||||||
envDir: string | boolean;
|
dir?: string | boolean;
|
||||||
/**
|
/**
|
||||||
* Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.
|
* Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.
|
||||||
*/
|
*/
|
||||||
prefixes: string | string[];
|
prefix?: string | string[];
|
||||||
};
|
};
|
||||||
apply(compiler: Compiler): void;
|
apply(compiler: Compiler): void;
|
||||||
|
|
||||||
|
@ -4392,14 +4464,14 @@ declare class DotenvPlugin {
|
||||||
*/
|
*/
|
||||||
declare interface DotenvPluginOptions {
|
declare interface DotenvPluginOptions {
|
||||||
/**
|
/**
|
||||||
* The directory from which .env files are loaded. Defaults to the webpack context. Loads .env, .env.local, .env.[mode], .env.[mode].local in order.
|
* The directory from which .env files are loaded. Can be an absolute path, or a path relative to the project root. false will disable the .env file loading.
|
||||||
*/
|
*/
|
||||||
envDir?: string;
|
dir?: string | boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.
|
* Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.
|
||||||
*/
|
*/
|
||||||
prefixes?: string | string[];
|
prefix?: string | string[];
|
||||||
}
|
}
|
||||||
declare class DynamicEntryPlugin {
|
declare class DynamicEntryPlugin {
|
||||||
constructor(context: string, entry: () => Promise<EntryStaticNormalized>);
|
constructor(context: string, entry: () => Promise<EntryStaticNormalized>);
|
||||||
|
@ -6659,6 +6731,33 @@ declare interface IteratorObject<T, TReturn = unknown, TNext = unknown>
|
||||||
[Symbol.iterator](): IteratorObject<T, TReturn, TNext>;
|
[Symbol.iterator](): IteratorObject<T, TReturn, TNext>;
|
||||||
[Symbol.dispose](): void;
|
[Symbol.dispose](): void;
|
||||||
}
|
}
|
||||||
|
declare abstract class JavascriptGenerator extends Generator {
|
||||||
|
generateError(
|
||||||
|
error: Error,
|
||||||
|
module: NormalModule,
|
||||||
|
generateContext: GenerateContext
|
||||||
|
): null | Source;
|
||||||
|
sourceModule(
|
||||||
|
module: Module,
|
||||||
|
initFragments: InitFragment<GenerateContext>[],
|
||||||
|
source: ReplaceSource,
|
||||||
|
generateContext: GenerateContext
|
||||||
|
): void;
|
||||||
|
sourceBlock(
|
||||||
|
module: Module,
|
||||||
|
block: DependenciesBlock,
|
||||||
|
initFragments: InitFragment<GenerateContext>[],
|
||||||
|
source: ReplaceSource,
|
||||||
|
generateContext: GenerateContext
|
||||||
|
): void;
|
||||||
|
sourceDependency(
|
||||||
|
module: Module,
|
||||||
|
dependency: Dependency,
|
||||||
|
initFragments: InitFragment<GenerateContext>[],
|
||||||
|
source: ReplaceSource,
|
||||||
|
generateContext: GenerateContext
|
||||||
|
): void;
|
||||||
|
}
|
||||||
declare class JavascriptModulesPlugin {
|
declare class JavascriptModulesPlugin {
|
||||||
constructor(options?: object);
|
constructor(options?: object);
|
||||||
options: object;
|
options: object;
|
||||||
|
@ -7143,15 +7242,15 @@ declare class JavascriptParser extends ParserClass {
|
||||||
[LogicalExpression],
|
[LogicalExpression],
|
||||||
boolean | void
|
boolean | void
|
||||||
>;
|
>;
|
||||||
program: SyncBailHook<[Program, Comment[]], boolean | void>;
|
program: SyncBailHook<[Program, CommentImport[]], boolean | void>;
|
||||||
terminate: SyncBailHook<[ReturnStatement | ThrowStatement], boolean | void>;
|
terminate: SyncBailHook<[ReturnStatement | ThrowStatement], boolean | void>;
|
||||||
finish: SyncBailHook<[Program, Comment[]], boolean | void>;
|
finish: SyncBailHook<[Program, CommentImport[]], boolean | void>;
|
||||||
unusedStatement: SyncBailHook<[Statement], boolean | void>;
|
unusedStatement: SyncBailHook<[Statement], boolean | void>;
|
||||||
}>;
|
}>;
|
||||||
sourceType: "module" | "auto" | "script";
|
sourceType: "module" | "auto" | "script";
|
||||||
scope: ScopeInfo;
|
scope: ScopeInfo;
|
||||||
state: ParserState;
|
state: ParserState;
|
||||||
comments?: Comment[];
|
comments?: CommentImport[];
|
||||||
semicolons?: Set<number>;
|
semicolons?: Set<number>;
|
||||||
statementPath?: StatementPathItem[];
|
statementPath?: StatementPathItem[];
|
||||||
prevStatement?:
|
prevStatement?:
|
||||||
|
@ -7975,7 +8074,7 @@ declare class JavascriptParser extends ParserClass {
|
||||||
| MaybeNamedClassDeclaration,
|
| MaybeNamedClassDeclaration,
|
||||||
commentsStartPos: number
|
commentsStartPos: number
|
||||||
): boolean;
|
): boolean;
|
||||||
getComments(range: [number, number]): Comment[];
|
getComments(range: [number, number]): CommentImport[];
|
||||||
isAsiPosition(pos: number): boolean;
|
isAsiPosition(pos: number): boolean;
|
||||||
setAsiPosition(pos: number): void;
|
setAsiPosition(pos: number): void;
|
||||||
unsetAsiPosition(pos: number): void;
|
unsetAsiPosition(pos: number): void;
|
||||||
|
@ -8011,7 +8110,7 @@ declare class JavascriptParser extends ParserClass {
|
||||||
evaluatedVariable(tagInfo: TagInfo): VariableInfo;
|
evaluatedVariable(tagInfo: TagInfo): VariableInfo;
|
||||||
parseCommentOptions(range: [number, number]): {
|
parseCommentOptions(range: [number, number]): {
|
||||||
options: null | Record<string, any>;
|
options: null | Record<string, any>;
|
||||||
errors: null | (Error & { comment: Comment })[];
|
errors: null | (Error & { comment: CommentImport })[];
|
||||||
};
|
};
|
||||||
extractMemberExpressionChain(
|
extractMemberExpressionChain(
|
||||||
expression:
|
expression:
|
||||||
|
@ -8363,6 +8462,14 @@ declare abstract class JsonData {
|
||||||
| JsonValueFs[];
|
| JsonValueFs[];
|
||||||
updateHash(hash: Hash): void;
|
updateHash(hash: Hash): void;
|
||||||
}
|
}
|
||||||
|
declare abstract class JsonGenerator extends Generator {
|
||||||
|
options: JsonGeneratorOptions;
|
||||||
|
generateError(
|
||||||
|
error: Error,
|
||||||
|
module: NormalModule,
|
||||||
|
generateContext: GenerateContext
|
||||||
|
): null | Source;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generator options for json modules.
|
* Generator options for json modules.
|
||||||
|
@ -8373,6 +8480,17 @@ declare interface JsonGeneratorOptions {
|
||||||
*/
|
*/
|
||||||
JSONParse?: boolean;
|
JSONParse?: boolean;
|
||||||
}
|
}
|
||||||
|
declare interface JsonModulesPluginParserOptions {
|
||||||
|
/**
|
||||||
|
* The depth of json dependency flagged as `exportInfo`.
|
||||||
|
*/
|
||||||
|
exportsDepth?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that executes for a module source string and should return json-compatible data.
|
||||||
|
*/
|
||||||
|
parse?: (input: string) => any;
|
||||||
|
}
|
||||||
declare interface JsonObjectFs {
|
declare interface JsonObjectFs {
|
||||||
[index: string]:
|
[index: string]:
|
||||||
| undefined
|
| undefined
|
||||||
|
@ -8393,6 +8511,9 @@ declare interface JsonObjectTypes {
|
||||||
| JsonObjectTypes
|
| JsonObjectTypes
|
||||||
| JsonValueTypes[];
|
| JsonValueTypes[];
|
||||||
}
|
}
|
||||||
|
declare abstract class JsonParser extends ParserClass {
|
||||||
|
options: JsonModulesPluginParserOptions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parser options for JSON modules.
|
* Parser options for JSON modules.
|
||||||
|
@ -11324,6 +11445,225 @@ declare abstract class NormalModuleFactory extends ModuleFactory {
|
||||||
],
|
],
|
||||||
Module
|
Module
|
||||||
>;
|
>;
|
||||||
|
createParser: TypedHookMap<
|
||||||
|
Record<
|
||||||
|
"javascript/auto",
|
||||||
|
SyncBailHook<[JavascriptParserOptions], JavascriptParser>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"javascript/dynamic",
|
||||||
|
SyncBailHook<[JavascriptParserOptions], JavascriptParser>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"javascript/esm",
|
||||||
|
SyncBailHook<[JavascriptParserOptions], JavascriptParser>
|
||||||
|
> &
|
||||||
|
Record<"json", SyncBailHook<[JsonParserOptions], JsonParser>> &
|
||||||
|
Record<"asset", SyncBailHook<[AssetParserOptions], AssetParser>> &
|
||||||
|
Record<
|
||||||
|
"asset/inline",
|
||||||
|
SyncBailHook<[EmptyParserOptions], AssetParser>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"asset/resource",
|
||||||
|
SyncBailHook<[EmptyParserOptions], AssetParser>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"asset/source",
|
||||||
|
SyncBailHook<[EmptyParserOptions], AssetSourceParser>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"asset/bytes",
|
||||||
|
SyncBailHook<[EmptyParserOptions], AssetBytesParser>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"webassembly/async",
|
||||||
|
SyncBailHook<[EmptyParserOptions], AsyncWebAssemblyParser>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"webassembly/sync",
|
||||||
|
SyncBailHook<[EmptyParserOptions], WebAssemblyParser>
|
||||||
|
> &
|
||||||
|
Record<"css", SyncBailHook<[CssParserOptions], CssParser>> &
|
||||||
|
Record<"css/auto", SyncBailHook<[CssAutoParserOptions], CssParser>> &
|
||||||
|
Record<
|
||||||
|
"css/module",
|
||||||
|
SyncBailHook<[CssModuleParserOptions], CssParser>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"css/global",
|
||||||
|
SyncBailHook<[CssGlobalParserOptions], CssParser>
|
||||||
|
> &
|
||||||
|
Record<string, SyncBailHook<[ParserOptions], ParserClass>>
|
||||||
|
>;
|
||||||
|
parser: TypedHookMap<
|
||||||
|
Record<
|
||||||
|
"javascript/auto",
|
||||||
|
SyncBailHook<[JavascriptParser, JavascriptParserOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"javascript/dynamic",
|
||||||
|
SyncBailHook<[JavascriptParser, JavascriptParserOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"javascript/esm",
|
||||||
|
SyncBailHook<[JavascriptParser, JavascriptParserOptions], void>
|
||||||
|
> &
|
||||||
|
Record<"json", SyncBailHook<[JsonParser, JsonParserOptions], void>> &
|
||||||
|
Record<"asset", SyncBailHook<[AssetParser, AssetParserOptions], void>> &
|
||||||
|
Record<
|
||||||
|
"asset/inline",
|
||||||
|
SyncBailHook<[AssetParser, EmptyParserOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"asset/resource",
|
||||||
|
SyncBailHook<[AssetParser, EmptyParserOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"asset/source",
|
||||||
|
SyncBailHook<[AssetSourceParser, EmptyParserOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"asset/bytes",
|
||||||
|
SyncBailHook<[AssetBytesParser, EmptyParserOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"webassembly/async",
|
||||||
|
SyncBailHook<[AsyncWebAssemblyParser, EmptyParserOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"webassembly/sync",
|
||||||
|
SyncBailHook<[WebAssemblyParser, EmptyParserOptions], void>
|
||||||
|
> &
|
||||||
|
Record<"css", SyncBailHook<[CssParser, CssParserOptions], void>> &
|
||||||
|
Record<
|
||||||
|
"css/auto",
|
||||||
|
SyncBailHook<[CssParser, CssAutoParserOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"css/module",
|
||||||
|
SyncBailHook<[CssParser, CssModuleParserOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"css/global",
|
||||||
|
SyncBailHook<[CssParser, CssGlobalParserOptions], void>
|
||||||
|
> &
|
||||||
|
Record<string, SyncBailHook<[ParserClass, ParserOptions], void>>
|
||||||
|
>;
|
||||||
|
createGenerator: TypedHookMap<
|
||||||
|
Record<
|
||||||
|
"javascript/auto",
|
||||||
|
SyncBailHook<[EmptyGeneratorOptions], JavascriptGenerator>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"javascript/dynamic",
|
||||||
|
SyncBailHook<[EmptyGeneratorOptions], JavascriptGenerator>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"javascript/esm",
|
||||||
|
SyncBailHook<[EmptyGeneratorOptions], JavascriptGenerator>
|
||||||
|
> &
|
||||||
|
Record<"json", SyncBailHook<[JsonGeneratorOptions], JsonGenerator>> &
|
||||||
|
Record<"asset", SyncBailHook<[AssetGeneratorOptions], AssetGenerator>> &
|
||||||
|
Record<
|
||||||
|
"asset/inline",
|
||||||
|
SyncBailHook<[AssetGeneratorOptions], AssetGenerator>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"asset/resource",
|
||||||
|
SyncBailHook<[AssetGeneratorOptions], AssetGenerator>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"asset/source",
|
||||||
|
SyncBailHook<[EmptyGeneratorOptions], AssetSourceGenerator>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"asset/bytes",
|
||||||
|
SyncBailHook<[EmptyGeneratorOptions], AssetBytesGenerator>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"webassembly/async",
|
||||||
|
SyncBailHook<[EmptyParserOptions], Generator>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"webassembly/sync",
|
||||||
|
SyncBailHook<[EmptyParserOptions], Generator>
|
||||||
|
> &
|
||||||
|
Record<"css", SyncBailHook<[CssGeneratorOptions], CssGenerator>> &
|
||||||
|
Record<
|
||||||
|
"css/auto",
|
||||||
|
SyncBailHook<[CssAutoGeneratorOptions], CssGenerator>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"css/module",
|
||||||
|
SyncBailHook<[CssModuleGeneratorOptions], CssGenerator>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"css/global",
|
||||||
|
SyncBailHook<[CssGlobalGeneratorOptions], CssGenerator>
|
||||||
|
> &
|
||||||
|
Record<string, SyncBailHook<[GeneratorOptions], Generator>>
|
||||||
|
>;
|
||||||
|
generator: TypedHookMap<
|
||||||
|
Record<
|
||||||
|
"javascript/auto",
|
||||||
|
SyncBailHook<[JavascriptGenerator, EmptyGeneratorOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"javascript/dynamic",
|
||||||
|
SyncBailHook<[JavascriptGenerator, EmptyGeneratorOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"javascript/esm",
|
||||||
|
SyncBailHook<[JavascriptGenerator, EmptyGeneratorOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"json",
|
||||||
|
SyncBailHook<[JsonGenerator, JsonGeneratorOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"asset",
|
||||||
|
SyncBailHook<[AssetGenerator, AssetGeneratorOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"asset/inline",
|
||||||
|
SyncBailHook<[AssetGenerator, AssetGeneratorOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"asset/resource",
|
||||||
|
SyncBailHook<[AssetGenerator, AssetGeneratorOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"asset/source",
|
||||||
|
SyncBailHook<[AssetSourceGenerator, EmptyGeneratorOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"asset/bytes",
|
||||||
|
SyncBailHook<[AssetBytesGenerator, EmptyGeneratorOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"webassembly/async",
|
||||||
|
SyncBailHook<[Generator, EmptyParserOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"webassembly/sync",
|
||||||
|
SyncBailHook<[Generator, EmptyParserOptions], void>
|
||||||
|
> &
|
||||||
|
Record<"css", SyncBailHook<[CssGenerator, CssGeneratorOptions], void>> &
|
||||||
|
Record<
|
||||||
|
"css/auto",
|
||||||
|
SyncBailHook<[CssGenerator, CssAutoGeneratorOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"css/module",
|
||||||
|
SyncBailHook<[CssGenerator, CssModuleGeneratorOptions], void>
|
||||||
|
> &
|
||||||
|
Record<
|
||||||
|
"css/global",
|
||||||
|
SyncBailHook<[CssGenerator, CssGlobalGeneratorOptions], void>
|
||||||
|
> &
|
||||||
|
Record<string, SyncBailHook<[Generator, GeneratorOptions], void>>
|
||||||
|
>;
|
||||||
createModuleClass: HookMap<
|
createModuleClass: HookMap<
|
||||||
SyncBailHook<
|
SyncBailHook<
|
||||||
[
|
[
|
||||||
|
@ -13196,6 +13536,10 @@ declare interface PnpApi {
|
||||||
options: { considerBuiltins: boolean }
|
options: { considerBuiltins: boolean }
|
||||||
) => null | string;
|
) => null | string;
|
||||||
}
|
}
|
||||||
|
declare interface Position {
|
||||||
|
line: number;
|
||||||
|
column: number;
|
||||||
|
}
|
||||||
declare class PrefetchPlugin {
|
declare class PrefetchPlugin {
|
||||||
constructor(context: string, request?: string);
|
constructor(context: string, request?: string);
|
||||||
context: null | string;
|
context: null | string;
|
||||||
|
@ -17845,6 +18189,7 @@ declare abstract class WeakTupleMap<K extends any[], V> {
|
||||||
delete(...args: K): void;
|
delete(...args: K): void;
|
||||||
clear(): void;
|
clear(): void;
|
||||||
}
|
}
|
||||||
|
declare abstract class WebAssemblyParser extends ParserClass {}
|
||||||
declare interface WebAssemblyRenderContext {
|
declare interface WebAssemblyRenderContext {
|
||||||
/**
|
/**
|
||||||
* the chunk
|
* the chunk
|
||||||
|
@ -18025,18 +18370,7 @@ declare interface WebpackOptionsNormalized {
|
||||||
/**
|
/**
|
||||||
* Enable and configure the Dotenv plugin to load environment variables from .env files.
|
* Enable and configure the Dotenv plugin to load environment variables from .env files.
|
||||||
*/
|
*/
|
||||||
dotenv?:
|
dotenv?: boolean | DotenvPluginOptions;
|
||||||
| boolean
|
|
||||||
| {
|
|
||||||
/**
|
|
||||||
* The directory from which .env files are loaded. Defaults to the webpack context. Loads .env, .env.local, .env.[mode], .env.[mode].local in order.
|
|
||||||
*/
|
|
||||||
envDir?: string;
|
|
||||||
/**
|
|
||||||
* Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.
|
|
||||||
*/
|
|
||||||
prefixes?: string | string[];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The entry point(s) of the compilation.
|
* The entry point(s) of the compilation.
|
||||||
|
@ -18241,36 +18575,10 @@ type WebpackOptionsNormalizedWithDefaults = WebpackOptionsNormalized & {
|
||||||
} & { recordsInputPath: NonNullable<undefined | string | false> } & {
|
} & { recordsInputPath: NonNullable<undefined | string | false> } & {
|
||||||
recordsOutputPath:
|
recordsOutputPath:
|
||||||
| (string & {
|
| (string & {
|
||||||
dotenv: NonNullable<
|
dotenv: NonNullable<undefined | boolean | DotenvPluginOptions>;
|
||||||
| undefined
|
|
||||||
| boolean
|
|
||||||
| {
|
|
||||||
/**
|
|
||||||
* The directory from which .env files are loaded. Defaults to the webpack context. Loads .env, .env.local, .env.[mode], .env.[mode].local in order.
|
|
||||||
*/
|
|
||||||
envDir?: string;
|
|
||||||
/**
|
|
||||||
* Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.
|
|
||||||
*/
|
|
||||||
prefixes?: string | string[];
|
|
||||||
}
|
|
||||||
>;
|
|
||||||
})
|
})
|
||||||
| (false & {
|
| (false & {
|
||||||
dotenv: NonNullable<
|
dotenv: NonNullable<undefined | boolean | DotenvPluginOptions>;
|
||||||
| undefined
|
|
||||||
| boolean
|
|
||||||
| {
|
|
||||||
/**
|
|
||||||
* The directory from which .env files are loaded. Defaults to the webpack context. Loads .env, .env.local, .env.[mode], .env.[mode].local in order.
|
|
||||||
*/
|
|
||||||
envDir?: string;
|
|
||||||
/**
|
|
||||||
* Only expose environment variables that start with these prefixes. Defaults to 'WEBPACK_'.
|
|
||||||
*/
|
|
||||||
prefixes?: string | string[];
|
|
||||||
}
|
|
||||||
>;
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue