How to use the @wordpress/scripts/config/webpack.config.externals function in @wordpress/scripts

To help you get started, we’ve selected a few @wordpress/scripts 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 insideout10 / wordlift-plugin / src-js / webpack / webpack.config.js View on Github external
test: /.svg$/,
        use: {
          loader: "svg-react-loader"
        }
      }
    ]
  },
  plugins: [
    ...defaultConfig.plugins,
    // @see https://webpack.js.org/loaders/sass-loader/#extracting-style-sheets
    new MiniCssExtractPlugin({
      filename: "[name].css"
    })
  ],
  externals: {
    ...defaultConfig.externals,
    backbone: "Backbone"
  }
};

// Create the full configuration for files that will include all the dependencies to keep WordPress pre 5.0.0 compatibility.
const webpackConfigFull = { ...webpackConfig };
// Remove the `DependencyExtractionWebpackPlugin`.
webpackConfigFull.plugins = webpackConfig.plugins.filter(
  entry => !(entry instanceof DependencyExtractionWebpackPlugin)
);

// Add the .full suffix to each entry.
webpackConfigFull.entry = Object.keys(webpackConfig.entry)
  .filter(entry => "block-editor" !== entry)
  .reduce((acc, key) => {
    acc[key + ".full"] = webpackConfig.entry[key];
github WordPress / health-check / webpack.config.js View on Github external
new CopyPlugin([
			{
				from: path.resolve( process.cwd(), 'src/php' ),
				to: path.resolve( process.cwd(), 'health-check' )
			},
			{
				from: path.resolve( process.cwd(), 'docs' ),
				to: path.resolve( process.cwd(), 'health-check' )
			}
		]),
		new MiniCssExtractPlugin({
			filename: '../css/[name].css',
		}),
	],
	externals: {
		...defaultConfig.externals,
		react: 'React',
		'react-dom': 'ReactDOM',
	}
};