2019-01-09 14:38:10 +01:00
|
|
|
const webpack = require('webpack');
|
2021-09-08 15:28:22 +02:00
|
|
|
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
|
2019-01-09 14:38:10 +01:00
|
|
|
const webpackTerserPlugin = require('terser-webpack-plugin');
|
2019-05-22 14:58:41 +02:00
|
|
|
const webpackCopyPlugin = require('copy-webpack-plugin');
|
2019-01-09 14:38:10 +01:00
|
|
|
const path = require('path');
|
2021-06-30 16:18:27 +02:00
|
|
|
const del = require('del');
|
2019-01-09 14:38:10 +01:00
|
|
|
const globalPrefix = 'MailPoetLib';
|
|
|
|
const PRODUCTION_ENV = process.env.NODE_ENV === 'production';
|
|
|
|
const manifestSeed = {};
|
2015-08-17 14:23:46 +03:00
|
|
|
|
2017-06-14 22:40:21 -04:00
|
|
|
// Base config
|
2019-01-09 14:38:10 +01:00
|
|
|
const baseConfig = {
|
2019-01-09 09:29:28 +01:00
|
|
|
mode: PRODUCTION_ENV ? 'production' : 'development',
|
2019-02-04 10:18:15 +01:00
|
|
|
devtool: PRODUCTION_ENV ? undefined : 'eval-source-map',
|
2017-06-14 22:40:21 -04:00
|
|
|
cache: true,
|
2021-08-10 15:00:56 +02:00
|
|
|
bail: PRODUCTION_ENV,
|
2015-08-17 14:23:46 +03:00
|
|
|
context: __dirname,
|
2018-06-13 13:33:27 +01:00
|
|
|
watchOptions: {
|
2015-10-21 15:24:51 -04:00
|
|
|
aggregateTimeout: 300,
|
|
|
|
poll: true
|
|
|
|
},
|
2019-01-09 09:29:28 +01:00
|
|
|
optimization: {
|
|
|
|
minimizer: [
|
2019-01-09 11:49:19 +01:00
|
|
|
new webpackTerserPlugin({
|
|
|
|
terserOptions: {
|
2019-01-14 12:49:30 +01:00
|
|
|
// preserve identifier names for easier debugging & support
|
2019-01-09 09:29:28 +01:00
|
|
|
mangle: false,
|
|
|
|
},
|
2019-02-05 15:50:05 +03:00
|
|
|
parallel: false,
|
2019-01-09 09:29:28 +01:00
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
2015-08-17 14:23:46 +03:00
|
|
|
output: {
|
2019-01-21 17:28:31 +01:00
|
|
|
path: path.join(__dirname, 'assets/dist/js'),
|
2018-10-02 09:51:34 +02:00
|
|
|
filename: (PRODUCTION_ENV) ? '[name].[hash:8].js' : '[name].js',
|
2019-01-03 20:51:52 +01:00
|
|
|
chunkFilename: (PRODUCTION_ENV) ? '[name].[hash:8].chunk.js' : '[name].chunk.js',
|
2015-08-17 14:23:46 +03:00
|
|
|
},
|
|
|
|
resolve: {
|
2018-06-13 13:33:27 +01:00
|
|
|
modules: [
|
2015-08-17 14:23:46 +03:00
|
|
|
'node_modules',
|
2016-02-22 11:44:06 -05:00
|
|
|
'assets/js/src',
|
2015-08-17 14:23:46 +03:00
|
|
|
],
|
2021-09-08 15:37:29 +02:00
|
|
|
fallback: {
|
|
|
|
fs: false,
|
2021-09-08 16:08:08 +02:00
|
|
|
path: false, // path is used in css module, but we don't use the functionality which requires it
|
2021-09-08 15:37:29 +02:00
|
|
|
},
|
2020-02-26 15:39:27 +01:00
|
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
2015-08-17 14:23:46 +03:00
|
|
|
alias: {
|
|
|
|
'handlebars': 'handlebars/dist/handlebars.js',
|
2015-08-19 16:26:38 +03:00
|
|
|
'backbone.marionette': 'backbone.marionette/lib/backbone.marionette',
|
2015-08-21 13:24:06 +03:00
|
|
|
'backbone.supermodel$': 'backbone.supermodel/build/backbone.supermodel.js',
|
2016-01-04 17:02:46 +02:00
|
|
|
'sticky-kit': 'vendor/jquery.sticky-kit.js',
|
2015-08-26 18:24:43 +03:00
|
|
|
'interact$': 'interact.js/interact.js',
|
2015-11-05 17:17:54 +02:00
|
|
|
'spectrum$': 'spectrum-colorpicker/spectrum.js',
|
2019-05-22 14:49:02 +03:00
|
|
|
'wp-js-hooks': path.resolve(__dirname, 'assets/js/src/hooks.js'),
|
2017-06-15 18:11:05 +01:00
|
|
|
'blob$': 'blob-tmp/Blob.js',
|
2015-11-13 14:45:25 +02:00
|
|
|
'papaparse': 'papaparse/papaparse.min.js',
|
2016-02-20 18:53:24 -05:00
|
|
|
'html2canvas': 'html2canvas/dist/html2canvas.js',
|
2018-11-22 18:05:34 +01:00
|
|
|
'asyncqueue': 'vendor/jquery.asyncqueue.js',
|
2015-08-26 18:24:43 +03:00
|
|
|
},
|
2015-08-17 14:23:46 +03:00
|
|
|
},
|
2021-06-30 16:18:27 +02:00
|
|
|
plugins: [],
|
2015-08-17 14:23:46 +03:00
|
|
|
module: {
|
2020-11-16 12:12:23 +01:00
|
|
|
noParse: /node_modules\/lodash\/lodash\.js/,
|
2018-06-13 13:33:27 +01:00
|
|
|
rules: [
|
2015-08-17 14:23:46 +03:00
|
|
|
{
|
2020-02-26 14:14:31 +01:00
|
|
|
test: /\.(j|t)sx?$/,
|
2019-02-20 11:20:33 +01:00
|
|
|
exclude: /(node_modules|src\/vendor)/,
|
2018-06-13 10:57:40 +01:00
|
|
|
loader: 'babel-loader',
|
2015-08-21 13:24:06 +03:00
|
|
|
},
|
2015-11-04 11:21:08 +01:00
|
|
|
{
|
|
|
|
test: /form_editor\.js$/,
|
2021-09-08 16:15:22 +02:00
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: 'WysijaForm',
|
|
|
|
},
|
2015-11-04 11:21:08 +01:00
|
|
|
},
|
2015-11-02 19:01:01 +01:00
|
|
|
{
|
|
|
|
include: require.resolve('codemirror'),
|
2021-09-08 16:15:22 +02:00
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: 'CodeMirror',
|
|
|
|
},
|
2015-11-02 19:01:01 +01:00
|
|
|
},
|
2015-08-21 13:24:06 +03:00
|
|
|
{
|
|
|
|
include: require.resolve('backbone'),
|
2021-09-08 16:15:22 +02:00
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: 'Backbone',
|
|
|
|
},
|
2015-08-21 13:24:06 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
include: require.resolve('underscore'),
|
2021-09-08 16:15:22 +02:00
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: '_',
|
|
|
|
},
|
2015-08-21 13:24:06 +03:00
|
|
|
},
|
2018-06-06 15:13:39 +01:00
|
|
|
{
|
|
|
|
include: require.resolve('react-tooltip'),
|
2021-09-08 16:15:22 +02:00
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: globalPrefix + '.ReactTooltip',
|
|
|
|
},
|
2018-06-06 15:13:39 +01:00
|
|
|
},
|
2017-03-01 14:30:24 +03:00
|
|
|
{
|
|
|
|
include: require.resolve('react'),
|
2021-09-08 16:15:22 +02:00
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: globalPrefix + '.React',
|
|
|
|
},
|
2017-03-01 14:30:24 +03:00
|
|
|
},
|
2017-09-12 16:30:56 +01:00
|
|
|
{
|
|
|
|
include: require.resolve('react-dom'),
|
2021-09-08 16:15:22 +02:00
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: globalPrefix + '.ReactDOM',
|
|
|
|
},
|
2017-09-12 16:30:56 +01:00
|
|
|
},
|
2017-04-04 15:37:16 +03:00
|
|
|
{
|
2018-11-14 15:03:28 +01:00
|
|
|
include: require.resolve('react-router-dom'),
|
2021-09-08 16:15:22 +02:00
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: globalPrefix + '.ReactRouter',
|
|
|
|
},
|
2017-04-04 15:37:16 +03:00
|
|
|
},
|
|
|
|
{
|
2017-03-01 14:30:24 +03:00
|
|
|
include: require.resolve('react-string-replace'),
|
2021-09-08 16:15:22 +02:00
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: globalPrefix + '.ReactStringReplace',
|
|
|
|
},
|
2017-03-01 14:30:24 +03:00
|
|
|
},
|
2017-02-28 17:58:04 +03:00
|
|
|
{
|
2019-05-22 14:49:02 +03:00
|
|
|
include: path.resolve(__dirname, 'assets/js/src/hooks.js'),
|
2021-09-08 16:15:22 +02:00
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: {
|
|
|
|
globalName: globalPrefix + '.Hooks',
|
|
|
|
override: true,
|
|
|
|
},
|
|
|
|
},
|
2017-02-28 17:58:04 +03:00
|
|
|
},
|
2017-04-04 15:37:16 +03:00
|
|
|
{
|
|
|
|
test: /listing.jsx/i,
|
2018-06-13 13:33:27 +01:00
|
|
|
use: [
|
2021-09-08 16:15:22 +02:00
|
|
|
{
|
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: globalPrefix + '.Listing',
|
|
|
|
},
|
|
|
|
},
|
2018-06-13 13:33:27 +01:00
|
|
|
'babel-loader'
|
|
|
|
],
|
2017-04-04 15:37:16 +03:00
|
|
|
},
|
2019-05-15 15:09:14 +02:00
|
|
|
{
|
|
|
|
include: path.resolve(__dirname, 'assets/js/src/help-tooltip.jsx'),
|
|
|
|
use: [
|
2021-09-08 16:15:22 +02:00
|
|
|
{
|
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: globalPrefix + '.HelpTooltip',
|
|
|
|
},
|
|
|
|
},
|
2019-05-15 15:09:14 +02:00
|
|
|
'babel-loader',
|
|
|
|
]
|
|
|
|
},
|
2020-08-27 10:15:09 +02:00
|
|
|
{
|
|
|
|
include: path.resolve(__dirname, 'assets/js/src/common/index.ts'),
|
|
|
|
use: [
|
2021-09-08 16:15:22 +02:00
|
|
|
{
|
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: globalPrefix + '.Common',
|
|
|
|
},
|
|
|
|
},
|
2020-08-27 10:15:09 +02:00
|
|
|
'babel-loader',
|
|
|
|
]
|
|
|
|
},
|
2015-11-05 17:17:54 +02:00
|
|
|
{
|
|
|
|
include: /Blob.js$/,
|
2021-09-08 16:15:22 +02:00
|
|
|
loader: 'exports-loader',
|
|
|
|
options: {
|
|
|
|
exports: 'default window.Blob',
|
|
|
|
}
|
2015-11-05 17:17:54 +02:00
|
|
|
},
|
2015-08-21 13:24:06 +03:00
|
|
|
{
|
2015-09-09 14:05:34 +03:00
|
|
|
test: /backbone.supermodel/,
|
2021-09-08 16:15:22 +02:00
|
|
|
loader: 'exports-loader',
|
|
|
|
options: {
|
|
|
|
exports: 'default Backbone.SuperModel',
|
|
|
|
}
|
2015-08-21 13:24:06 +03:00
|
|
|
},
|
2015-08-26 18:24:43 +03:00
|
|
|
{
|
|
|
|
include: require.resolve('handlebars'),
|
2021-09-08 16:15:22 +02:00
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: 'Handlebars',
|
|
|
|
},
|
2015-08-26 18:24:43 +03:00
|
|
|
},
|
2016-01-05 15:01:30 +02:00
|
|
|
{
|
|
|
|
include: require.resolve('velocity-animate'),
|
2021-09-08 16:15:22 +02:00
|
|
|
loader: 'imports-loader',
|
|
|
|
options: {
|
|
|
|
imports: {
|
|
|
|
name: 'jQuery',
|
|
|
|
moduleName: 'jquery',
|
|
|
|
},
|
|
|
|
},
|
2016-01-05 15:01:30 +02:00
|
|
|
},
|
2018-03-29 16:22:08 -04:00
|
|
|
{
|
|
|
|
include: require.resolve('classnames'),
|
2018-06-13 13:33:27 +01:00
|
|
|
use: [
|
2021-09-08 16:15:22 +02:00
|
|
|
{
|
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: globalPrefix + '.ClassNames',
|
|
|
|
},
|
|
|
|
},
|
2018-06-13 13:33:27 +01:00
|
|
|
'babel-loader',
|
|
|
|
]
|
2018-03-29 16:22:08 -04:00
|
|
|
},
|
2019-05-23 08:34:08 +02:00
|
|
|
{
|
|
|
|
test: /node_modules\/tinymce/,
|
|
|
|
loader: 'string-replace-loader',
|
|
|
|
options: {
|
|
|
|
// prefix TinyMCE to avoid conflicts with other plugins
|
|
|
|
multiple: [
|
|
|
|
{
|
|
|
|
search: 'window\\.tinymce',
|
|
|
|
replace: 'window.mailpoetTinymce',
|
|
|
|
flags: 'g',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
search: 'tinymce\\.util',
|
|
|
|
replace: 'window.mailpoetTinymce.util',
|
|
|
|
flags: 'g',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
search: 'resolve\\(\'tinymce',
|
|
|
|
replace: 'resolve(\'mailpoetTinymce',
|
|
|
|
flags: 'g',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2015-08-17 14:23:46 +03:00
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-06-14 22:40:21 -04:00
|
|
|
// Admin config
|
2019-01-09 14:38:10 +01:00
|
|
|
const adminConfig = {
|
2015-08-17 14:23:46 +03:00
|
|
|
name: 'admin',
|
|
|
|
entry: {
|
2018-11-26 15:01:10 +01:00
|
|
|
vendor: 'webpack_vendor_index.jsx',
|
|
|
|
mailpoet: 'webpack_mailpoet_index.jsx',
|
2018-12-11 12:11:39 +01:00
|
|
|
admin_vendor: [
|
|
|
|
'react',
|
|
|
|
'react-dom',
|
|
|
|
require.resolve('react-router-dom'),
|
|
|
|
'react-string-replace',
|
|
|
|
'prop-types',
|
|
|
|
'classnames',
|
2021-08-12 16:11:10 +02:00
|
|
|
'lodash',
|
|
|
|
'@emotion/react',
|
|
|
|
'@emotion/styled',
|
2019-05-15 15:09:14 +02:00
|
|
|
'help-tooltip.jsx',
|
2018-12-11 12:11:39 +01:00
|
|
|
'listing/listing.jsx',
|
2020-08-27 10:15:09 +02:00
|
|
|
'common/index.ts',
|
2018-12-11 12:11:39 +01:00
|
|
|
],
|
2018-11-26 15:01:10 +01:00
|
|
|
admin: 'webpack_admin_index.jsx',
|
|
|
|
newsletter_editor: 'newsletter_editor/webpack_index.jsx',
|
2021-08-12 16:11:10 +02:00
|
|
|
form_editor: 'form_editor/form_editor.jsx',
|
|
|
|
settings: 'settings/index.tsx'
|
2015-08-17 14:23:46 +03:00
|
|
|
},
|
2019-05-22 14:58:41 +02:00
|
|
|
plugins: [
|
|
|
|
...baseConfig.plugins,
|
|
|
|
|
2020-06-04 10:11:19 +02:00
|
|
|
new webpackCopyPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: 'node_modules/tinymce/skins/ui/oxide',
|
|
|
|
to: 'skins/ui/oxide'
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
2019-05-22 14:58:41 +02:00
|
|
|
],
|
2019-01-09 09:29:28 +01:00
|
|
|
optimization: {
|
2021-09-08 16:17:24 +02:00
|
|
|
runtimeChunk: 'single',
|
2019-01-09 09:29:28 +01:00
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
|
|
|
chunks: 'all',
|
2021-09-08 16:17:24 +02:00
|
|
|
},
|
2019-01-09 09:29:28 +01:00
|
|
|
}
|
|
|
|
},
|
2015-08-17 14:23:46 +03:00
|
|
|
externals: {
|
2015-08-25 14:48:04 +03:00
|
|
|
'jquery': 'jQuery',
|
2021-09-08 16:17:24 +02:00
|
|
|
},
|
2017-06-14 22:40:21 -04:00
|
|
|
};
|
2015-08-17 14:23:46 +03:00
|
|
|
|
2017-06-14 22:40:21 -04:00
|
|
|
// Public config
|
2019-01-09 14:38:10 +01:00
|
|
|
const publicConfig = {
|
2015-08-17 14:23:46 +03:00
|
|
|
name: 'public',
|
|
|
|
entry: {
|
2018-11-26 15:01:10 +01:00
|
|
|
public: 'webpack_public_index.jsx',
|
2015-08-17 14:23:46 +03:00
|
|
|
},
|
2018-11-28 14:06:02 +01:00
|
|
|
plugins: [
|
2018-12-03 15:44:35 +01:00
|
|
|
...baseConfig.plugins,
|
|
|
|
|
2018-11-28 14:06:02 +01:00
|
|
|
// replace MailPoet definition with a smaller version for public
|
|
|
|
new webpack.NormalModuleReplacementPlugin(
|
|
|
|
/mailpoet\.js/,
|
|
|
|
'./mailpoet_public.js'
|
|
|
|
),
|
|
|
|
],
|
2015-08-17 14:23:46 +03:00
|
|
|
externals: {
|
|
|
|
'jquery': 'jQuery'
|
|
|
|
}
|
2017-06-14 22:40:21 -04:00
|
|
|
};
|
2015-08-17 14:23:46 +03:00
|
|
|
|
2017-06-14 22:40:21 -04:00
|
|
|
// Migrator config
|
2019-01-09 14:38:10 +01:00
|
|
|
const migratorConfig = {
|
2017-04-18 19:15:12 +02:00
|
|
|
name: 'mp2migrator',
|
|
|
|
entry: {
|
|
|
|
mp2migrator: [
|
|
|
|
'mp2migrator.js'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
externals: {
|
2017-05-17 17:35:42 +02:00
|
|
|
'jquery': 'jQuery',
|
|
|
|
'mailpoet': 'MailPoet'
|
2017-04-18 19:15:12 +02:00
|
|
|
}
|
2017-06-14 22:40:21 -04:00
|
|
|
};
|
2019-01-09 09:29:28 +01:00
|
|
|
|
2019-11-27 11:06:41 +01:00
|
|
|
// Newsletter Editor Tests Config
|
2019-01-09 14:38:10 +01:00
|
|
|
const testConfig = {
|
2015-08-17 14:23:46 +03:00
|
|
|
name: 'test',
|
|
|
|
entry: {
|
2018-11-26 15:01:10 +01:00
|
|
|
vendor: 'webpack_vendor_index.jsx',
|
2015-08-26 18:24:43 +03:00
|
|
|
testNewsletterEditor: [
|
2018-11-26 15:01:10 +01:00
|
|
|
'webpack_mailpoet_index.jsx',
|
|
|
|
'newsletter_editor/webpack_index.jsx',
|
2015-08-26 18:24:43 +03:00
|
|
|
|
|
|
|
'components/config.spec.js',
|
|
|
|
'components/content.spec.js',
|
|
|
|
'components/heading.spec.js',
|
2019-05-28 12:46:05 +02:00
|
|
|
'components/history.spec.js',
|
2015-08-26 18:24:43 +03:00
|
|
|
'components/save.spec.js',
|
|
|
|
'components/sidebar.spec.js',
|
|
|
|
'components/styles.spec.js',
|
2015-12-16 18:06:28 +02:00
|
|
|
'components/communication.spec.js',
|
2015-08-26 18:24:43 +03:00
|
|
|
|
2019-02-27 18:07:35 +01:00
|
|
|
'blocks/automatedLatestContentLayout.spec.js',
|
2015-08-26 18:24:43 +03:00
|
|
|
'blocks/button.spec.js',
|
|
|
|
'blocks/container.spec.js',
|
|
|
|
'blocks/divider.spec.js',
|
|
|
|
'blocks/footer.spec.js',
|
|
|
|
'blocks/header.spec.js',
|
|
|
|
'blocks/image.spec.js',
|
|
|
|
'blocks/posts.spec.js',
|
2019-04-08 16:11:02 +02:00
|
|
|
'blocks/products.spec.js',
|
2015-08-26 18:24:43 +03:00
|
|
|
'blocks/social.spec.js',
|
|
|
|
'blocks/spacer.spec.js',
|
|
|
|
'blocks/text.spec.js',
|
|
|
|
],
|
2015-08-17 14:23:46 +03:00
|
|
|
},
|
|
|
|
output: {
|
2019-11-27 11:06:41 +01:00
|
|
|
path: path.join(__dirname, 'tests/javascript_newsletter_editor/testBundles'),
|
2015-08-17 14:23:46 +03:00
|
|
|
filename: '[name].js',
|
|
|
|
},
|
2018-11-28 14:06:02 +01:00
|
|
|
plugins: [
|
2018-12-03 15:44:35 +01:00
|
|
|
...baseConfig.plugins,
|
|
|
|
|
2018-11-28 14:06:02 +01:00
|
|
|
// replace MailPoet definition with a smaller version for public
|
|
|
|
new webpack.NormalModuleReplacementPlugin(
|
|
|
|
/mailpoet\.js/,
|
|
|
|
'./mailpoet_tests.js'
|
|
|
|
),
|
|
|
|
],
|
2015-08-17 14:23:46 +03:00
|
|
|
resolve: {
|
2018-06-13 13:33:27 +01:00
|
|
|
modules: [
|
2015-08-17 14:23:46 +03:00
|
|
|
'node_modules',
|
|
|
|
'assets/js/src',
|
2019-11-27 11:06:41 +01:00
|
|
|
'tests/javascript_newsletter_editor/newsletter_editor'
|
2015-08-26 18:24:43 +03:00
|
|
|
],
|
2020-11-10 19:27:17 +01:00
|
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
2015-08-26 18:24:43 +03:00
|
|
|
alias: {
|
2021-09-08 16:16:21 +02:00
|
|
|
'handlebars': 'handlebars/dist/handlebars.js',
|
2016-01-04 17:02:46 +02:00
|
|
|
'sticky-kit': 'vendor/jquery.sticky-kit.js',
|
2015-08-26 18:24:43 +03:00
|
|
|
'backbone.marionette': 'backbone.marionette/lib/backbone.marionette',
|
|
|
|
'backbone.supermodel$': 'backbone.supermodel/build/backbone.supermodel.js',
|
2018-11-26 15:01:10 +01:00
|
|
|
'blob$': 'blob-tmp/Blob.js',
|
2019-05-22 14:49:02 +03:00
|
|
|
'wp-js-hooks': path.resolve(__dirname, 'assets/js/src/hooks.js'),
|
2015-08-26 18:24:43 +03:00
|
|
|
},
|
2021-09-08 15:37:29 +02:00
|
|
|
fallback: {
|
|
|
|
fs: false,
|
|
|
|
},
|
2015-08-26 18:24:43 +03:00
|
|
|
},
|
|
|
|
externals: {
|
|
|
|
'jquery': 'jQuery',
|
|
|
|
'interact': 'interact',
|
|
|
|
'spectrum': 'spectrum',
|
2019-10-16 15:14:25 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-05-19 16:57:02 +02:00
|
|
|
// Form preview config
|
|
|
|
const formPreviewConfig = {
|
|
|
|
name: 'form_preview',
|
|
|
|
entry: {
|
|
|
|
form_preview: 'form_editor/form_preview.ts',
|
|
|
|
},
|
|
|
|
externals: {
|
|
|
|
'jquery': 'jQuery',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-01-30 14:05:51 +01:00
|
|
|
// Block config
|
|
|
|
const postEditorBlock = {
|
|
|
|
name: 'post_editor_block',
|
|
|
|
entry: {
|
|
|
|
post_editor_block: 'post_editor_block/blocks.jsx',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-08-12 16:11:10 +02:00
|
|
|
module.exports = [adminConfig, publicConfig, migratorConfig, formPreviewConfig, testConfig, postEditorBlock].map((config) => {
|
2017-06-14 22:40:21 -04:00
|
|
|
if (config.name !== 'test') {
|
|
|
|
config.plugins = config.plugins || [];
|
|
|
|
config.plugins.push(
|
2021-09-08 15:28:22 +02:00
|
|
|
new WebpackManifestPlugin({
|
2019-01-14 12:49:30 +01:00
|
|
|
// create single manifest file for all Webpack configs
|
2019-01-09 09:29:28 +01:00
|
|
|
seed: manifestSeed,
|
2017-06-14 22:40:21 -04:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2021-06-30 16:18:27 +02:00
|
|
|
// Clean output paths before build
|
|
|
|
if (config.output && config.output.path) {
|
|
|
|
del.sync([path.resolve(config.output.path, '**/*')]);
|
|
|
|
}
|
2019-01-09 14:35:20 +01:00
|
|
|
return Object.assign({}, baseConfig, config);
|
2017-08-31 12:02:20 +03:00
|
|
|
});
|