-
Notifications
You must be signed in to change notification settings - Fork 882
/
webpack.config.js
67 lines (63 loc) · 2 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// External dependencies
const { readdirSync } = require( "fs" );
const { join } = require( "path" );
// Variables
const root = join( __dirname, "../../" );
// Internal dependencies
const paths = require( "./paths" );
const packageJson = require( root + "package.json" );
const baseConfig = require( "./webpack.config.base" );
const {
yoastPackages,
yoastExternals,
} = require( "./externals" );
const languages = readdirSync( root + "node_modules/yoastseo/src/languageProcessing/languages" );
const pluginVersion = packageJson.yoast.pluginVersion;
const pluginVersionSlug = paths.flattenVersionForFile( pluginVersion );
const outputFilename = "[name].js";
module.exports = [
baseConfig(
{
entry: paths.entry,
output: {
path: paths.jsDist,
filename: outputFilename,
},
combinedOutputFile: root + "src/generated/assets/plugin.php",
cssExtractFileName: "../../../css/dist/plugin-" + pluginVersionSlug + ".css",
},
),
baseConfig(
{
entry: yoastPackages.reduce( ( memo, packageName ) => {
memo[ yoastExternals[ packageName ] ] = "./node_modules/" + packageName;
return memo;
}, {} ),
output: {
path: paths.jsDist + "/externals",
filename: outputFilename,
library: [ "yoast", "[name]" ],
libraryTarget: "window",
},
combinedOutputFile: root + "src/generated/assets/externals.php",
cssExtractFileName: "../../../css/dist/monorepo-" + pluginVersionSlug + ".css",
},
),
baseConfig(
{
entry: languages.reduce( ( memo, language ) => {
const name = ( language === "_default" ) ? "default" : language;
memo[ name ] = "./node_modules/yoastseo/src/languageProcessing/languages/" + language + "/Researcher";
return memo;
}, {} ),
output: {
path: paths.jsDist + "/languages",
filename: outputFilename,
library: [ "yoast", "Researcher" ],
libraryTarget: "window",
},
combinedOutputFile: root + "src/generated/assets/languages.php",
cssExtractFileName: "../../../css/dist/languages-" + pluginVersionSlug + ".css",
},
),
];