webpack.config.js 1.64 KiB
/**
 * External dependencies
 */
 const webpack = require("webpack");
 const entryPointNames = [
   'block-civicrm'
 ];
 const externals = {};
 entryPointNames.forEach(entryPointName => {
   externals["@/" + entryPointName] = {
     this: ["", entryPointName]
 });
 const wpDependencies = [
   "components",
   "element",
   "editor",
   "blocks",
   "hooks",
   "data",
   "editPost",
   "i18n"
 wpDependencies.forEach(wpDependency => {
   externals["@wordpress/" + wpDependency] = {
     this: ["wp", wpDependency]
 });
 const config = {
   entry: entryPointNames.reduce((memo, entryPointName) => {
     memo[entryPointName] = "./src/javascript/" + entryPointName + ".jsx";
     return memo;
   }, {}),
   externals,
   output: {
     filename: "assets/built/js/[name].min.js",
     path: __dirname,
     library: ["bfc", "[name]"],
     libraryTarget: "this"
   resolve: {
     modules: [__dirname, "node_modules"]
   module: {
     rules: [
         test: /\.jsx$/,
         exclude: /node_modules/,
         use: "babel-loader"
   plugins: [
     new webpack.DefinePlugin({
       "process.env.NODE_ENV": JSON.stringify(
         process.env.NODE_ENV || "development"
     }),
     new webpack.LoaderOptionsPlugin({
       minimize: process.env.NODE_ENV === "development",
       debug: process.env.NODE_ENV !== "development"
     }),
   stats: {
     children: false
71727374757677787980818283
}; switch (process.env.node_env) { case "development": // config.plugins.push(new webpack.optimize.UglifyJsPlugin()); break; default: config.devtool = "source-map"; } module.exports = config;