fix(plugins): fix global process variable
This commit is contained in:
parent
bfb61db6a8
commit
11fc2d47a7
@ -1,5 +1,6 @@
|
|||||||
import type webpack from 'webpack';
|
import type webpack from 'webpack';
|
||||||
import type { WebpackOptions } from 'types';
|
import type { WebpackOptions } from 'types';
|
||||||
|
import getProvidePlugin from './provide-plugin';
|
||||||
import getBundleAnalyzerPlugin from './bundle-analyzer-plugin';
|
import getBundleAnalyzerPlugin from './bundle-analyzer-plugin';
|
||||||
import getCopyPlugin from './copy-plugin';
|
import getCopyPlugin from './copy-plugin';
|
||||||
import getDefinePlugin from './define-plugin';
|
import getDefinePlugin from './define-plugin';
|
||||||
@ -20,6 +21,7 @@ const createPlugins = (options: WebpackOptions): webpack.Configuration['plugins'
|
|||||||
const developmentPlugins = [
|
const developmentPlugins = [
|
||||||
getHtmlPlugin(options),
|
getHtmlPlugin(options),
|
||||||
getProgressPlugin(options),
|
getProgressPlugin(options),
|
||||||
|
getProvidePlugin(options),
|
||||||
getDefinePlugin(options),
|
getDefinePlugin(options),
|
||||||
getForkTsCheckerPlugin(options),
|
getForkTsCheckerPlugin(options),
|
||||||
getEslintPlugin(options),
|
getEslintPlugin(options),
|
||||||
@ -29,6 +31,7 @@ const createPlugins = (options: WebpackOptions): webpack.Configuration['plugins'
|
|||||||
|
|
||||||
const productionPlugins = [
|
const productionPlugins = [
|
||||||
getHtmlPlugin(options),
|
getHtmlPlugin(options),
|
||||||
|
getProvidePlugin(options),
|
||||||
getDefinePlugin(options),
|
getDefinePlugin(options),
|
||||||
getMiniCssPlugin(options),
|
getMiniCssPlugin(options),
|
||||||
getForkTsCheckerPlugin(options),
|
getForkTsCheckerPlugin(options),
|
||||||
|
|||||||
21
src/plugins/provide-plugin/index.ts
Normal file
21
src/plugins/provide-plugin/index.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import type { WebpackOptions } from 'types';
|
||||||
|
import { ProvidePlugin } from 'webpack';
|
||||||
|
|
||||||
|
const getProvidePlugin = (options: WebpackOptions) => {
|
||||||
|
const {
|
||||||
|
plugins: {
|
||||||
|
providePlugin,
|
||||||
|
} = {},
|
||||||
|
} = options;
|
||||||
|
|
||||||
|
if (providePlugin === 'off') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ProvidePlugin({
|
||||||
|
process: 'process/browser',
|
||||||
|
...providePlugin,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default getProvidePlugin;
|
||||||
Loading…
x
Reference in New Issue
Block a user