How to use the webpack-merge.unique function in webpack-merge

To help you get started, we’ve selected a few webpack-merge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github storybookjs / vue-cli-plugin-storybook / generator / template / config / storybook / webpack.config.js View on Github external
module.exports = (storybookBaseConfig, configType) => {
  const storybookConfig = genStorybookDefaultConfig(
    storybookBaseConfig,
    configType
  );

  return {
    ...vueConfig, // use vue's webpack configuration by default
    entry: storybookConfig.entry, // overwite entry
    output: storybookConfig.output, // overwrite output
    // remove duplicated plugins
    plugins: merge({
      customizeArray: merge.unique(
        "plugins",
        [
          "HotModuleReplacementPlugin",
          "CaseSensitivePathsPlugin",
          "WatchMissingNodeModulesPlugin"
        ],
        plugin => plugin.constructor && plugin.constructor.name
      )
    })(vueConfig, storybookConfig).plugins,
    resolve: {
      ...vueConfig.resolve,
      alias: {
        ...vueConfig.resolve.alias,
        vue$: storybookConfig.resolve.alias.vue$
      }
    }
github styleguidist / react-styleguidist / src / scripts / utils / mergeWebpackConfig.ts View on Github external
};

const IGNORE_PLUGINS = [
	'CommonsChunkPlugins',
	'MiniHtmlWebpackPlugin',
	'HtmlWebpackPlugin',
	'OccurrenceOrderPlugin',
	'DedupePlugin',
	'UglifyJsPlugin',
	'TerserPlugin',
	'HotModuleReplacementPlugin',
];

const merge = mergeBase({
	// Ignore user’s plugins to avoid duplicates and issues with our plugins
	customizeArray: mergeBase.unique(
		'plugins',
		IGNORE_PLUGINS,
		(plugin: Tapable.Plugin) => plugin.constructor && plugin.constructor.name
	),
});

type MetaConfig = Configuration | ((env?: string) => Configuration);

/**
 * Merge two Webpack configs.
 *
 * In the user config:
 * - Ignores given sections (options.ignore).
 * - Ignores plugins that shouldn’t be used twice or may cause issues.
 *
 * @param {object} baseConfig
github vue-styleguidist / vue-styleguidist / packages / vue-styleguidist / src / scripts / utils / mergeWebpackConfig.ts View on Github external
removePlugins: ['plugins']
}

const IGNORE_PLUGINS = [
	'CommonsChunkPlugins',
	'MiniHtmlWebpackPlugin',
	'HtmlWebpackPlugin',
	'OccurrenceOrderPlugin',
	'DedupePlugin',
	'UglifyJsPlugin',
	'HotModuleReplacementPlugin'
]

const merge = mergeBase({
	// Ignore user’s plugins to avoid duplicates and issues with our plugins
	customizeArray: mergeBase.unique(
		'plugins',
		IGNORE_PLUGINS,
		(plugin: Plugin) => plugin.constructor && plugin.constructor.name
	)
})

//make it a typeguard
function isFunc(
	conf: Configuration | ((env: string) => Configuration)
): conf is ((env: string) => Configuration) {
	return isFunction(conf)
}

/**
 * Merge two Webpack configs.
 *