@teambit/webpack 0.0.621 → 0.0.629
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__preview-1642994756471.js +1 -0
- package/config/html.ts +1 -1
- package/config/webpack-fallbacks.ts +1 -1
- package/config/webpack.config.ts +100 -10
- package/config/webpack.dev.config.ts +3 -1
- package/dist/config/html.js +1 -1
- package/dist/config/html.js.map +1 -1
- package/dist/config/webpack-fallbacks.js.map +1 -1
- package/dist/config/webpack.config.d.ts +3 -1
- package/dist/config/webpack.config.js +159 -9
- package/dist/config/webpack.config.js.map +1 -1
- package/dist/config/webpack.dev.config.js +3 -1
- package/dist/config/webpack.dev.config.js.map +1 -1
- package/dist/webpack.bundler.d.ts +4 -3
- package/dist/webpack.bundler.js +14 -0
- package/dist/webpack.bundler.js.map +1 -1
- package/dist/webpack.main.runtime.d.ts +0 -3
- package/dist/webpack.main.runtime.js +4 -29
- package/dist/webpack.main.runtime.js.map +1 -1
- package/package-tar/teambit-webpack-0.0.629.tgz +0 -0
- package/package.json +14 -9
- package/config/webpack-preview.config.ts +0 -59
- package/dist/config/webpack-preview.config.d.ts +0 -2
- package/dist/config/webpack-preview.config.js +0 -109
- package/dist/config/webpack-preview.config.js.map +0 -1
- package/package-tar/teambit-webpack-0.0.621.tgz +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.webpack_webpack@0.0.629/dist/webpack.composition.js')]
|
package/config/html.ts
CHANGED
package/config/webpack.config.ts
CHANGED
|
@@ -1,24 +1,44 @@
|
|
|
1
|
+
import camelcase from 'camelcase';
|
|
1
2
|
import webpack, { Configuration } from 'webpack';
|
|
3
|
+
import { generateExternals } from '@teambit/webpack.modules.generate-externals';
|
|
4
|
+
import { isUndefined, omitBy } from 'lodash';
|
|
5
|
+
import type { BundlerContext, BundlerHtmlConfig, Target } from '@teambit/bundler';
|
|
6
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
7
|
+
import WebpackAssetsManifest from 'webpack-assets-manifest';
|
|
2
8
|
import { fallbacks } from './webpack-fallbacks';
|
|
3
9
|
import { fallbacksProvidePluginConfig } from './webpack-fallbacks-provide-plugin-config';
|
|
4
10
|
import { fallbacksAliases } from './webpack-fallbacks-aliases';
|
|
5
11
|
|
|
6
|
-
export function configFactory(
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
export function configFactory(target: Target, context: BundlerContext): Configuration {
|
|
13
|
+
const truthyEntries =
|
|
14
|
+
Array.isArray(target.entries) && target.entries.length ? target.entries.filter(Boolean) : target.entries || {};
|
|
15
|
+
const dev = Boolean(context.development);
|
|
16
|
+
const htmlConfig = target.html ?? context.html;
|
|
17
|
+
const htmlPlugins = htmlConfig ? generateHtmlPlugins(htmlConfig) : undefined;
|
|
18
|
+
const shouldExternalizePeers =
|
|
19
|
+
(target.externalizePeer ?? context.externalizePeer) && target.peers && target.peers.length;
|
|
20
|
+
const externals = shouldExternalizePeers ? (getExternals(target.peers || []) as any) : undefined;
|
|
21
|
+
const splitChunks = target.chunking?.splitChunks;
|
|
22
|
+
|
|
23
|
+
const config: Configuration = {
|
|
24
|
+
mode: dev ? 'development' : 'production',
|
|
9
25
|
// Stop compilation early in production
|
|
10
26
|
bail: true,
|
|
11
27
|
// These are the "entry points" to our application.
|
|
12
28
|
// This means they will be the "root" imports that are included in JS bundle.
|
|
13
|
-
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
entry: truthyEntries,
|
|
31
|
+
|
|
32
|
+
infrastructureLogging: {
|
|
33
|
+
level: 'error',
|
|
34
|
+
},
|
|
14
35
|
|
|
15
36
|
output: {
|
|
16
37
|
// The build folder.
|
|
17
|
-
path: `${
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
chunkFilename: 'static/js/[name].[contenthash:8].chunk.js',
|
|
38
|
+
path: `${target.outputPath}/public`,
|
|
39
|
+
},
|
|
40
|
+
stats: {
|
|
41
|
+
errorDetails: true,
|
|
22
42
|
},
|
|
23
43
|
|
|
24
44
|
resolve: {
|
|
@@ -27,6 +47,76 @@ export function configFactory(entries: string[], rootPath: string): Configuratio
|
|
|
27
47
|
fallback: fallbacks,
|
|
28
48
|
},
|
|
29
49
|
|
|
30
|
-
plugins: [new webpack.ProvidePlugin(fallbacksProvidePluginConfig)],
|
|
50
|
+
plugins: [new webpack.ProvidePlugin(fallbacksProvidePluginConfig), getAssetManifestPlugin()],
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
if (target.filename) {
|
|
54
|
+
config.output = config.output || {};
|
|
55
|
+
config.output.filename = target.filename;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (target.chunkFilename) {
|
|
59
|
+
config.output = config.output || {};
|
|
60
|
+
config.output.chunkFilename = target.chunkFilename;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (target.runtimeChunkName) {
|
|
64
|
+
config.optimization = config.optimization || {};
|
|
65
|
+
config.optimization.runtimeChunk = {
|
|
66
|
+
name: target.runtimeChunkName,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (splitChunks) {
|
|
71
|
+
config.optimization = config.optimization || {};
|
|
72
|
+
config.optimization.splitChunks = {
|
|
73
|
+
chunks: 'all',
|
|
74
|
+
name: false,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (htmlPlugins && htmlPlugins.length) {
|
|
79
|
+
if (!config.plugins) {
|
|
80
|
+
config.plugins = [];
|
|
81
|
+
}
|
|
82
|
+
config.plugins = config.plugins.concat(htmlPlugins);
|
|
83
|
+
}
|
|
84
|
+
if (externals) {
|
|
85
|
+
config.externals = externals;
|
|
86
|
+
}
|
|
87
|
+
return config;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function getAssetManifestPlugin() {
|
|
91
|
+
return new WebpackAssetsManifest({ entrypoints: true });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function generateHtmlPlugins(configs: BundlerHtmlConfig[]) {
|
|
95
|
+
return configs.map((config) => generateHtmlPlugin(config));
|
|
96
|
+
}
|
|
97
|
+
function generateHtmlPlugin(config: BundlerHtmlConfig) {
|
|
98
|
+
const baseConfig = {
|
|
99
|
+
filename: config.filename,
|
|
100
|
+
chunks: config.chunks,
|
|
101
|
+
title: config.title,
|
|
102
|
+
templateContent: config.templateContent,
|
|
103
|
+
minify: config.minify,
|
|
104
|
+
cache: false,
|
|
105
|
+
chunksSortMode: 'auto' as const,
|
|
31
106
|
};
|
|
107
|
+
if (baseConfig.chunks && baseConfig.chunks.length) {
|
|
108
|
+
// Make sure the order is that the preview root coming after the preview def
|
|
109
|
+
// we can't make it like this on the entries using depend on because this will
|
|
110
|
+
// prevent the splitting between different preview defs
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
baseConfig.chunksSortMode = 'manual' as const;
|
|
113
|
+
}
|
|
114
|
+
const filteredConfig = omitBy(baseConfig, isUndefined);
|
|
115
|
+
return new HtmlWebpackPlugin(filteredConfig);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function getExternals(deps: string[]) {
|
|
119
|
+
return generateExternals(deps, {
|
|
120
|
+
transformName: (depName) => camelcase(depName.replace('@', '').replace('/', '-'), { pascalCase: true }),
|
|
121
|
+
});
|
|
32
122
|
}
|
package/dist/config/html.js
CHANGED
package/dist/config/html.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["html.ts"],"names":["html","title"],"mappings":";;;;;;;AAAA;AACO,SAASA,IAAT,CAAcC,KAAd,EAA6B;AAClC,SAAO,MAAO;AAChB;AACA;AACA;AACA;AACA;AACA,eAAeA,KAAM;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAlBE;AAmBD","sourcesContent":["/** html template for Previews (docs, compositions, etc) */\nexport function html(title: string) {\n return () => `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>${title}</title>\n <script>\n // Allow to use react dev-tools inside the examples\n try { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__; } catch {}\n </script>\n <!-- minimal css resets -->\n <style> html { height: 100%; } body { margin: 0; height: 100%; } #root { height: 100%; } </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n </html
|
|
1
|
+
{"version":3,"sources":["html.ts"],"names":["html","title"],"mappings":";;;;;;;AAAA;AACO,SAASA,IAAT,CAAcC,KAAd,EAA6B;AAClC,SAAO,MAAO;AAChB;AACA;AACA;AACA;AACA;AACA,eAAeA,KAAM;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAlBE;AAmBD","sourcesContent":["/** html template for Previews (docs, compositions, etc) */\nexport function html(title: string) {\n return () => `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>${title}</title>\n <script>\n // Allow to use react dev-tools inside the examples\n try { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__; } catch {}\n </script>\n <!-- minimal css resets -->\n <style> html { height: 100%; } body { margin: 0; height: 100%; } #root { height: 100%; } </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n </html>\n `;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack-fallbacks.ts"],"names":["assertFallbackPath","require","resolve","bufferFallbackPath","constantsFallbackPath","cryptoFallbackPath","domainFallbackPath","httpFallbackPath","httpsFallbackPath","osFallbackPath","pathFallbackPath","punycodeFallbackPath","processFallbackPath","querystringFallbackPath","streamFallbackPath","string_decoderFallbackPath","sysFallbackPath","timersFallbackPath","ttyFallbackPath","urlFallbackPath","utilFallbackPath","vmFallbackPath","zlibFallbackPath","fallbacks","assert","buffer","constants","crypto","domain","http","https","os","path","punycode","process","querystring","stream","string_decoder","sys","timers","tty","url","util","vm","zlib","fs","net","tls","child_process"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEA,MAAMA,kBAAkB,GAAGC,OAAO,CAACC,OAAR,CAAgB,SAAhB,CAA3B;;AACA,MAAMC,kBAAkB,GAAGF,OAAO,CAACC,OAAR,CAAgB,SAAhB,CAA3B;;AACA,MAAME,qBAAqB,GAAGH,OAAO,CAACC,OAAR,CAAgB,sBAAhB,CAA9B;;AACA,MAAMG,kBAAkB,GAAGJ,OAAO,CAACC,OAAR,CAAgB,mBAAhB,CAA3B;;AACA,MAAMI,kBAAkB,GAAGL,OAAO,CAACC,OAAR,CAAgB,gBAAhB,CAA3B;;AACA,MAAMK,gBAAgB,GAAGN,OAAO,CAACC,OAAR,CAAgB,aAAhB,CAAzB;;AACA,MAAMM,iBAAiB,GAAGP,OAAO,CAACC,OAAR,CAAgB,kBAAhB,CAA1B;;AACA,MAAMO,cAAc,GAAGR,OAAO,CAACC,OAAR,CAAgB,uBAAhB,CAAvB;;AACA,MAAMQ,gBAAgB,GAAGT,OAAO,CAACC,OAAR,CAAgB,iBAAhB,CAAzB;;AACA,MAAMS,oBAAoB,GAAGV,OAAO,CAACC,OAAR,CAAgB,WAAhB,CAA7B;;AACA,MAAMU,mBAAmB,GAAGX,OAAO,CAACC,OAAR,CAAgB,iBAAhB,CAA5B,C,CACA;;;AACA,MAAMW,uBAAuB,GAAGZ,OAAO,CAACC,OAAR,CAAgB,iBAAhB,CAAhC;;AACA,MAAMY,kBAAkB,GAAGb,OAAO,CAACC,OAAR,CAAgB,mBAAhB,CAA3B;;AACA,MAAMa,0BAA0B,GAAGd,OAAO,CAACC,OAAR,CAAgB,iBAAhB,CAAnC;;AACA,MAAMc,eAAe,GAAGf,OAAO,CAACC,OAAR,CAAgB,OAA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,cApBmB;AAqBvBuB,EAAAA,IAAI,EAAEtB,gBArBiB;AAsBvBuB,EAAAA,EAAE,EAAE,KAtBmB;AAuBvBC,EAAAA,GAAG,EAAE,KAvBkB;AAwBvBC,EAAAA,GAAG,EAAE,KAxBkB;AAyBvBC,EAAAA,aAAa,EAAE,KAzBQ,CA0BvB;AACA;AACA;AACA;AACA;;AA9BuB,CAAlB","sourcesContent":["// based on https://github1s.com/vercel/next.js/blob/canary/packages/next/build/webpack-config.ts\n// Full list of old polyfills is accessible here:\n// https://github.com/webpack/webpack/blob/2a0536cf510768111a3a6dceeb14cb79b9f59273/lib/ModuleNotFoundError.js#L13-L42\n\nconst assertFallbackPath = require.resolve('assert/');\nconst bufferFallbackPath = require.resolve('buffer/');\nconst constantsFallbackPath = require.resolve('constants-browserify');\nconst cryptoFallbackPath = require.resolve('crypto-browserify');\nconst domainFallbackPath = require.resolve('domain-browser');\nconst httpFallbackPath = require.resolve('stream-http');\nconst httpsFallbackPath = require.resolve('https-browserify');\nconst osFallbackPath = require.resolve('os-browserify/browser');\nconst pathFallbackPath = require.resolve('path-browserify');\nconst punycodeFallbackPath = require.resolve('punycode/');\nconst processFallbackPath = require.resolve('process/browser');\n// Handled in separate alias\nconst querystringFallbackPath = require.resolve('querystring-es3');\nconst streamFallbackPath = require.resolve('stream-browserify');\nconst string_decoderFallbackPath = require.resolve('string_decoder/');\nconst sysFallbackPath = require.resolve('util/');\nconst timersFallbackPath = require.resolve('timers-browserify');\nconst ttyFallbackPath = require.resolve('tty-browserify');\n// Handled in separate alias\nconst urlFallbackPath = require.resolve('url/');\nconst utilFallbackPath = require.resolve('util/');\nconst vmFallbackPath = require.resolve('vm-browserify');\nconst zlibFallbackPath = require.resolve('browserify-zlib');\n\nexport const fallbacks = {\n assert: assertFallbackPath,\n buffer: bufferFallbackPath,\n constants: constantsFallbackPath,\n crypto: cryptoFallbackPath,\n domain: domainFallbackPath,\n http: httpFallbackPath,\n https: httpsFallbackPath,\n os: osFallbackPath,\n path: pathFallbackPath,\n punycode: punycodeFallbackPath,\n process: processFallbackPath,\n querystring: querystringFallbackPath,\n stream: streamFallbackPath,\n string_decoder: string_decoderFallbackPath,\n sys: sysFallbackPath,\n timers: timersFallbackPath,\n tty: ttyFallbackPath,\n url: urlFallbackPath,\n util: utilFallbackPath,\n vm: vmFallbackPath,\n zlib: zlibFallbackPath,\n fs: false,\n net: false,\n tls: false,\n child_process: false,\n // file: false,\n // module: false,\n // pnpapi: false,\n // readline: false,\n // worker_threads: false,\n} as const
|
|
1
|
+
{"version":3,"sources":["webpack-fallbacks.ts"],"names":["assertFallbackPath","require","resolve","bufferFallbackPath","constantsFallbackPath","cryptoFallbackPath","domainFallbackPath","httpFallbackPath","httpsFallbackPath","osFallbackPath","pathFallbackPath","punycodeFallbackPath","processFallbackPath","querystringFallbackPath","streamFallbackPath","string_decoderFallbackPath","sysFallbackPath","timersFallbackPath","ttyFallbackPath","urlFallbackPath","utilFallbackPath","vmFallbackPath","zlibFallbackPath","fallbacks","assert","buffer","constants","crypto","domain","http","https","os","path","punycode","process","querystring","stream","string_decoder","sys","timers","tty","url","util","vm","zlib","fs","net","tls","child_process"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEA,MAAMA,kBAAkB,GAAGC,OAAO,CAACC,OAAR,CAAgB,SAAhB,CAA3B;;AACA,MAAMC,kBAAkB,GAAGF,OAAO,CAACC,OAAR,CAAgB,SAAhB,CAA3B;;AACA,MAAME,qBAAqB,GAAGH,OAAO,CAACC,OAAR,CAAgB,sBAAhB,CAA9B;;AACA,MAAMG,kBAAkB,GAAGJ,OAAO,CAACC,OAAR,CAAgB,mBAAhB,CAA3B;;AACA,MAAMI,kBAAkB,GAAGL,OAAO,CAACC,OAAR,CAAgB,gBAAhB,CAA3B;;AACA,MAAMK,gBAAgB,GAAGN,OAAO,CAACC,OAAR,CAAgB,aAAhB,CAAzB;;AACA,MAAMM,iBAAiB,GAAGP,OAAO,CAACC,OAAR,CAAgB,kBAAhB,CAA1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AEtB,gBANiB;AAOvBuB,EAAAA,KAAK,EAAEtB,iBAPgB;AAQvBuB,EAAAA,EAAE,EAAEtB,cARmB;AASvBuB,EAAAA,IAAI,EAAEtB,gBATiB;AAUvBuB,EAAAA,QAAQ,EAAEtB,oBAVa;AAWvBuB,EAAAA,OAAO,EAAEtB,mBAXc;AAYvBuB,EAAAA,WAAW,EAAEtB,uBAZU;AAavBuB,EAAAA,MAAM,EAAEtB,kBAbe;AAcvBuB,EAAAA,cAAc,EAAEtB,0BAdO;AAevBuB,EAAAA,GAAG,EAAEtB,eAfkB;AAgBvBuB,EAAAA,MAAM,EAAEtB,kBAhBe;AAiBvBuB,EAAAA,GAAG,EAAEtB,eAjBkB;AAkBvBuB,EAAAA,GAAG,EAAEtB,eAlBkB;AAmBvBuB,EAAAA,IAAI,EAAEtB,gBAnBiB;AAoBvBuB,EAAAA,EAAE,EAAEtB,cApBmB;AAqBvBuB,EAAAA,IAAI,EAAEtB,gBArBiB;AAsBvBuB,EAAAA,EAAE,EAAE,KAtBmB;AAuBvBC,EAAAA,GAAG,EAAE,KAvBkB;AAwBvBC,EAAAA,GAAG,EAAE,KAxBkB;AAyBvBC,EAAAA,aAAa,EAAE,KAzBQ,CA0BvB;AACA;AACA;AACA;AACA;;AA9BuB,CAAlB","sourcesContent":["// based on https://github1s.com/vercel/next.js/blob/canary/packages/next/build/webpack-config.ts\n// Full list of old polyfills is accessible here:\n// https://github.com/webpack/webpack/blob/2a0536cf510768111a3a6dceeb14cb79b9f59273/lib/ModuleNotFoundError.js#L13-L42\n\nconst assertFallbackPath = require.resolve('assert/');\nconst bufferFallbackPath = require.resolve('buffer/');\nconst constantsFallbackPath = require.resolve('constants-browserify');\nconst cryptoFallbackPath = require.resolve('crypto-browserify');\nconst domainFallbackPath = require.resolve('domain-browser');\nconst httpFallbackPath = require.resolve('stream-http');\nconst httpsFallbackPath = require.resolve('https-browserify');\nconst osFallbackPath = require.resolve('os-browserify/browser');\nconst pathFallbackPath = require.resolve('path-browserify');\nconst punycodeFallbackPath = require.resolve('punycode/');\nconst processFallbackPath = require.resolve('process/browser');\n// Handled in separate alias\nconst querystringFallbackPath = require.resolve('querystring-es3');\nconst streamFallbackPath = require.resolve('stream-browserify');\nconst string_decoderFallbackPath = require.resolve('string_decoder/');\nconst sysFallbackPath = require.resolve('util/');\nconst timersFallbackPath = require.resolve('timers-browserify');\nconst ttyFallbackPath = require.resolve('tty-browserify');\n// Handled in separate alias\nconst urlFallbackPath = require.resolve('url/');\nconst utilFallbackPath = require.resolve('util/');\nconst vmFallbackPath = require.resolve('vm-browserify');\nconst zlibFallbackPath = require.resolve('browserify-zlib');\n\nexport const fallbacks = {\n assert: assertFallbackPath,\n buffer: bufferFallbackPath,\n constants: constantsFallbackPath,\n crypto: cryptoFallbackPath,\n domain: domainFallbackPath,\n http: httpFallbackPath,\n https: httpsFallbackPath,\n os: osFallbackPath,\n path: pathFallbackPath,\n punycode: punycodeFallbackPath,\n process: processFallbackPath,\n querystring: querystringFallbackPath,\n stream: streamFallbackPath,\n string_decoder: string_decoderFallbackPath,\n sys: sysFallbackPath,\n timers: timersFallbackPath,\n tty: ttyFallbackPath,\n url: urlFallbackPath,\n util: utilFallbackPath,\n vm: vmFallbackPath,\n zlib: zlibFallbackPath,\n fs: false,\n net: false,\n tls: false,\n child_process: false,\n // file: false,\n // module: false,\n // pnpapi: false,\n // readline: false,\n // worker_threads: false,\n} as const;\n"]}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { Configuration } from 'webpack';
|
|
2
|
-
|
|
2
|
+
import type { BundlerContext, Target } from '@teambit/bundler';
|
|
3
|
+
export declare function configFactory(target: Target, context: BundlerContext): Configuration;
|
|
4
|
+
export declare function getExternals(deps: string[]): Object;
|
|
@@ -2,10 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
require("core-js/modules/es.array.iterator.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
8
|
+
|
|
9
|
+
require("core-js/modules/es.string.replace.js");
|
|
10
|
+
|
|
5
11
|
Object.defineProperty(exports, "__esModule", {
|
|
6
12
|
value: true
|
|
7
13
|
});
|
|
8
14
|
exports.configFactory = configFactory;
|
|
15
|
+
exports.getExternals = getExternals;
|
|
16
|
+
|
|
17
|
+
function _camelcase() {
|
|
18
|
+
const data = _interopRequireDefault(require("camelcase"));
|
|
19
|
+
|
|
20
|
+
_camelcase = function () {
|
|
21
|
+
return data;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
9
26
|
|
|
10
27
|
function _webpack() {
|
|
11
28
|
const data = _interopRequireDefault(require("webpack"));
|
|
@@ -17,6 +34,46 @@ function _webpack() {
|
|
|
17
34
|
return data;
|
|
18
35
|
}
|
|
19
36
|
|
|
37
|
+
function _webpackModules() {
|
|
38
|
+
const data = require("@teambit/webpack.modules.generate-externals");
|
|
39
|
+
|
|
40
|
+
_webpackModules = function () {
|
|
41
|
+
return data;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function _lodash() {
|
|
48
|
+
const data = require("lodash");
|
|
49
|
+
|
|
50
|
+
_lodash = function () {
|
|
51
|
+
return data;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function _htmlWebpackPlugin() {
|
|
58
|
+
const data = _interopRequireDefault(require("html-webpack-plugin"));
|
|
59
|
+
|
|
60
|
+
_htmlWebpackPlugin = function () {
|
|
61
|
+
return data;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function _webpackAssetsManifest() {
|
|
68
|
+
const data = _interopRequireDefault(require("webpack-assets-manifest"));
|
|
69
|
+
|
|
70
|
+
_webpackAssetsManifest = function () {
|
|
71
|
+
return data;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return data;
|
|
75
|
+
}
|
|
76
|
+
|
|
20
77
|
function _webpackFallbacks() {
|
|
21
78
|
const data = require("./webpack-fallbacks");
|
|
22
79
|
|
|
@@ -47,27 +104,120 @@ function _webpackFallbacksAliases() {
|
|
|
47
104
|
return data;
|
|
48
105
|
}
|
|
49
106
|
|
|
50
|
-
function configFactory(
|
|
51
|
-
|
|
52
|
-
|
|
107
|
+
function configFactory(target, context) {
|
|
108
|
+
var _target$html, _target$externalizePe, _target$chunking;
|
|
109
|
+
|
|
110
|
+
const truthyEntries = Array.isArray(target.entries) && target.entries.length ? target.entries.filter(Boolean) : target.entries || {};
|
|
111
|
+
const dev = Boolean(context.development);
|
|
112
|
+
const htmlConfig = (_target$html = target.html) !== null && _target$html !== void 0 ? _target$html : context.html;
|
|
113
|
+
const htmlPlugins = htmlConfig ? generateHtmlPlugins(htmlConfig) : undefined;
|
|
114
|
+
const shouldExternalizePeers = ((_target$externalizePe = target.externalizePeer) !== null && _target$externalizePe !== void 0 ? _target$externalizePe : context.externalizePeer) && target.peers && target.peers.length;
|
|
115
|
+
const externals = shouldExternalizePeers ? getExternals(target.peers || []) : undefined;
|
|
116
|
+
const splitChunks = (_target$chunking = target.chunking) === null || _target$chunking === void 0 ? void 0 : _target$chunking.splitChunks;
|
|
117
|
+
const config = {
|
|
118
|
+
mode: dev ? 'development' : 'production',
|
|
53
119
|
// Stop compilation early in production
|
|
54
120
|
bail: true,
|
|
55
121
|
// These are the "entry points" to our application.
|
|
56
122
|
// This means they will be the "root" imports that are included in JS bundle.
|
|
57
|
-
|
|
123
|
+
// @ts-ignore
|
|
124
|
+
entry: truthyEntries,
|
|
125
|
+
infrastructureLogging: {
|
|
126
|
+
level: 'error'
|
|
127
|
+
},
|
|
58
128
|
output: {
|
|
59
129
|
// The build folder.
|
|
60
|
-
path: `${
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
130
|
+
path: `${target.outputPath}/public`
|
|
131
|
+
},
|
|
132
|
+
stats: {
|
|
133
|
+
errorDetails: true
|
|
64
134
|
},
|
|
65
135
|
resolve: {
|
|
66
136
|
alias: _webpackFallbacksAliases().fallbacksAliases,
|
|
67
137
|
fallback: _webpackFallbacks().fallbacks
|
|
68
138
|
},
|
|
69
|
-
plugins: [new (_webpack().default.ProvidePlugin)(_webpackFallbacksProvidePluginConfig().fallbacksProvidePluginConfig)]
|
|
139
|
+
plugins: [new (_webpack().default.ProvidePlugin)(_webpackFallbacksProvidePluginConfig().fallbacksProvidePluginConfig), getAssetManifestPlugin()]
|
|
70
140
|
};
|
|
141
|
+
|
|
142
|
+
if (target.filename) {
|
|
143
|
+
config.output = config.output || {};
|
|
144
|
+
config.output.filename = target.filename;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (target.chunkFilename) {
|
|
148
|
+
config.output = config.output || {};
|
|
149
|
+
config.output.chunkFilename = target.chunkFilename;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (target.runtimeChunkName) {
|
|
153
|
+
config.optimization = config.optimization || {};
|
|
154
|
+
config.optimization.runtimeChunk = {
|
|
155
|
+
name: target.runtimeChunkName
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (splitChunks) {
|
|
160
|
+
config.optimization = config.optimization || {};
|
|
161
|
+
config.optimization.splitChunks = {
|
|
162
|
+
chunks: 'all',
|
|
163
|
+
name: false
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (htmlPlugins && htmlPlugins.length) {
|
|
168
|
+
if (!config.plugins) {
|
|
169
|
+
config.plugins = [];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
config.plugins = config.plugins.concat(htmlPlugins);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (externals) {
|
|
176
|
+
config.externals = externals;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return config;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function getAssetManifestPlugin() {
|
|
183
|
+
return new (_webpackAssetsManifest().default)({
|
|
184
|
+
entrypoints: true
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function generateHtmlPlugins(configs) {
|
|
189
|
+
return configs.map(config => generateHtmlPlugin(config));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function generateHtmlPlugin(config) {
|
|
193
|
+
const baseConfig = {
|
|
194
|
+
filename: config.filename,
|
|
195
|
+
chunks: config.chunks,
|
|
196
|
+
title: config.title,
|
|
197
|
+
templateContent: config.templateContent,
|
|
198
|
+
minify: config.minify,
|
|
199
|
+
cache: false,
|
|
200
|
+
chunksSortMode: 'auto'
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
if (baseConfig.chunks && baseConfig.chunks.length) {
|
|
204
|
+
// Make sure the order is that the preview root coming after the preview def
|
|
205
|
+
// we can't make it like this on the entries using depend on because this will
|
|
206
|
+
// prevent the splitting between different preview defs
|
|
207
|
+
// @ts-ignore
|
|
208
|
+
baseConfig.chunksSortMode = 'manual';
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const filteredConfig = (0, _lodash().omitBy)(baseConfig, _lodash().isUndefined);
|
|
212
|
+
return new (_htmlWebpackPlugin().default)(filteredConfig);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function getExternals(deps) {
|
|
216
|
+
return (0, _webpackModules().generateExternals)(deps, {
|
|
217
|
+
transformName: depName => (0, _camelcase().default)(depName.replace('@', '').replace('/', '-'), {
|
|
218
|
+
pascalCase: true
|
|
219
|
+
})
|
|
220
|
+
});
|
|
71
221
|
}
|
|
72
222
|
|
|
73
223
|
//# sourceMappingURL=webpack.config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack.config.ts"],"names":["configFactory","entries","
|
|
1
|
+
{"version":3,"sources":["webpack.config.ts"],"names":["configFactory","target","context","truthyEntries","Array","isArray","entries","length","filter","Boolean","dev","development","htmlConfig","html","htmlPlugins","generateHtmlPlugins","undefined","shouldExternalizePeers","externalizePeer","peers","externals","getExternals","splitChunks","chunking","config","mode","bail","entry","infrastructureLogging","level","output","path","outputPath","stats","errorDetails","resolve","alias","fallbacksAliases","fallback","fallbacks","plugins","webpack","ProvidePlugin","fallbacksProvidePluginConfig","getAssetManifestPlugin","filename","chunkFilename","runtimeChunkName","optimization","runtimeChunk","name","chunks","concat","WebpackAssetsManifest","entrypoints","configs","map","generateHtmlPlugin","baseConfig","title","templateContent","minify","cache","chunksSortMode","filteredConfig","isUndefined","HtmlWebpackPlugin","deps","transformName","depName","replace","pascalCase"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,SAASA,aAAT,CAAuBC,MAAvB,EAAuCC,OAAvC,EAA+E;AAAA;;AACpF,QAAMC,aAAa,GACjBC,KAAK,CAACC,OAAN,CAAcJ,MAAM,CAACK,OAArB,KAAiCL,MAAM,CAACK,OAAP,CAAeC,MAAhD,GAAyDN,MAAM,CAACK,OAAP,CAAeE,MAAf,CAAsBC,OAAtB,CAAzD,GAA0FR,MAAM,CAACK,OAAP,IAAkB,EAD9G;AAEA,QAAMI,GAAG,GAAGD,OAAO,CAACP,OAAO,CAACS,WAAT,CAAnB;AACA,QAAMC,UAAU,mBAAGX,MAAM,CAACY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AT,CAA6BwC,OAA7B,EAA2D;AACzD,SAAOA,OAAO,CAACC,GAAR,CAAahC,MAAD,IAAYiC,kBAAkB,CAACjC,MAAD,CAA1C,CAAP;AACD;;AACD,SAASiC,kBAAT,CAA4BjC,MAA5B,EAAuD;AACrD,QAAMkC,UAAU,GAAG;AACjBb,IAAAA,QAAQ,EAAErB,MAAM,CAACqB,QADA;AAEjBM,IAAAA,MAAM,EAAE3B,MAAM,CAAC2B,MAFE;AAGjBQ,IAAAA,KAAK,EAAEnC,MAAM,CAACmC,KAHG;AAIjBC,IAAAA,eAAe,EAAEpC,MAAM,CAACoC,eAJP;AAKjBC,IAAAA,MAAM,EAAErC,MAAM,CAACqC,MALE;AAMjBC,IAAAA,KAAK,EAAE,KANU;AAOjBC,IAAAA,cAAc,EAAE;AAPC,GAAnB;;AASA,MAAIL,UAAU,CAACP,MAAX,IAAqBO,UAAU,CAACP,MAAX,CAAkB5C,MAA3C,EAAmD;AACjD;AACA;AACA;AACA;AACAmD,IAAAA,UAAU,CAACK,cAAX,GAA4B,QAA5B;AACD;;AACD,QAAMC,cAAc,GAAG,sBAAON,UAAP,EAAmBO,qBAAnB,CAAvB;AACA,SAAO,KAAIC,4BAAJ,EAAsBF,cAAtB,CAAP;AACD;;AAEM,SAAS3C,YAAT,CAAsB8C,IAAtB,EAAsC;AAC3C,SAAO,yCAAkBA,IAAlB,EAAwB;AAC7BC,IAAAA,aAAa,EAAGC,OAAD,IAAa,0BAAUA,OAAO,CAACC,OAAR,CAAgB,GAAhB,EAAqB,EAArB,EAAyBA,OAAzB,CAAiC,GAAjC,EAAsC,GAAtC,CAAV,EAAsD;AAAEC,MAAAA,UAAU,EAAE;AAAd,KAAtD;AADC,GAAxB,CAAP;AAGD","sourcesContent":["import camelcase from 'camelcase';\nimport webpack, { Configuration } from 'webpack';\nimport { generateExternals } from '@teambit/webpack.modules.generate-externals';\nimport { isUndefined, omitBy } from 'lodash';\nimport type { BundlerContext, BundlerHtmlConfig, Target } from '@teambit/bundler';\nimport HtmlWebpackPlugin from 'html-webpack-plugin';\nimport WebpackAssetsManifest from 'webpack-assets-manifest';\nimport { fallbacks } from './webpack-fallbacks';\nimport { fallbacksProvidePluginConfig } from './webpack-fallbacks-provide-plugin-config';\nimport { fallbacksAliases } from './webpack-fallbacks-aliases';\n\nexport function configFactory(target: Target, context: BundlerContext): Configuration {\n const truthyEntries =\n Array.isArray(target.entries) && target.entries.length ? target.entries.filter(Boolean) : target.entries || {};\n const dev = Boolean(context.development);\n const htmlConfig = target.html ?? context.html;\n const htmlPlugins = htmlConfig ? generateHtmlPlugins(htmlConfig) : undefined;\n const shouldExternalizePeers =\n (target.externalizePeer ?? context.externalizePeer) && target.peers && target.peers.length;\n const externals = shouldExternalizePeers ? (getExternals(target.peers || []) as any) : undefined;\n const splitChunks = target.chunking?.splitChunks;\n\n const config: Configuration = {\n mode: dev ? 'development' : 'production',\n // Stop compilation early in production\n bail: true,\n // These are the \"entry points\" to our application.\n // This means they will be the \"root\" imports that are included in JS bundle.\n // @ts-ignore\n entry: truthyEntries,\n\n infrastructureLogging: {\n level: 'error',\n },\n\n output: {\n // The build folder.\n path: `${target.outputPath}/public`,\n },\n stats: {\n errorDetails: true,\n },\n\n resolve: {\n alias: fallbacksAliases,\n\n fallback: fallbacks,\n },\n\n plugins: [new webpack.ProvidePlugin(fallbacksProvidePluginConfig), getAssetManifestPlugin()],\n };\n\n if (target.filename) {\n config.output = config.output || {};\n config.output.filename = target.filename;\n }\n\n if (target.chunkFilename) {\n config.output = config.output || {};\n config.output.chunkFilename = target.chunkFilename;\n }\n\n if (target.runtimeChunkName) {\n config.optimization = config.optimization || {};\n config.optimization.runtimeChunk = {\n name: target.runtimeChunkName,\n };\n }\n\n if (splitChunks) {\n config.optimization = config.optimization || {};\n config.optimization.splitChunks = {\n chunks: 'all',\n name: false,\n };\n }\n\n if (htmlPlugins && htmlPlugins.length) {\n if (!config.plugins) {\n config.plugins = [];\n }\n config.plugins = config.plugins.concat(htmlPlugins);\n }\n if (externals) {\n config.externals = externals;\n }\n return config;\n}\n\nfunction getAssetManifestPlugin() {\n return new WebpackAssetsManifest({ entrypoints: true });\n}\n\nfunction generateHtmlPlugins(configs: BundlerHtmlConfig[]) {\n return configs.map((config) => generateHtmlPlugin(config));\n}\nfunction generateHtmlPlugin(config: BundlerHtmlConfig) {\n const baseConfig = {\n filename: config.filename,\n chunks: config.chunks,\n title: config.title,\n templateContent: config.templateContent,\n minify: config.minify,\n cache: false,\n chunksSortMode: 'auto' as const,\n };\n if (baseConfig.chunks && baseConfig.chunks.length) {\n // Make sure the order is that the preview root coming after the preview def\n // we can't make it like this on the entries using depend on because this will\n // prevent the splitting between different preview defs\n // @ts-ignore\n baseConfig.chunksSortMode = 'manual' as const;\n }\n const filteredConfig = omitBy(baseConfig, isUndefined);\n return new HtmlWebpackPlugin(filteredConfig);\n}\n\nexport function getExternals(deps: string[]) {\n return generateExternals(deps, {\n transformName: (depName) => camelcase(depName.replace('@', '').replace('/', '-'), { pascalCase: true }),\n });\n}\n"]}
|
|
@@ -178,7 +178,9 @@ function configFactory(devServerID, workspaceDir, entryFiles, publicRoot, public
|
|
|
178
178
|
infrastructureLogging: {
|
|
179
179
|
level: 'error'
|
|
180
180
|
},
|
|
181
|
-
stats:
|
|
181
|
+
stats: {
|
|
182
|
+
errorDetails: true
|
|
183
|
+
},
|
|
182
184
|
devServer: {
|
|
183
185
|
allowedHosts: 'all',
|
|
184
186
|
static: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack.dev.config.ts"],"names":["publicUrlOrPath","process","env","NODE_ENV","configFactory","devServerID","workspaceDir","entryFiles","publicRoot","publicPath","pubsub","title","resolveWorkspacePath","relativePath","path","resolve","publicDirectory","mode","devtool","entry","map","filePath","output","filename","pathinfo","chunkFilename","devtoolModuleFilenameTemplate","info","absoluteResourcePath","infrastructureLogging","level","stats","devServer","allowedHosts","static","directory","staticOptions","serveIndex","watch","compress","hot","historyApiFallback","disableDotRule","index","client","overlay","onBeforeSetupMiddleware","app","server","use","onAfterSetupMiddleware","devMiddleware","join","extensions","alias","fallbacksAliases","fallback","fallbacks","plugins","HtmlWebpackPlugin","templateContent","webpack","ProvidePlugin","fallbacksProvidePluginConfig","WebpackBitReporterPlugin","options"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA,MAAMA,eAAe,GAAG,mCAAmBC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAA5C,EAA2D,GAA3D,EAAgE,SAAhE,CAAxB;;AAEO,SAASC,aAAT,CACLC,WADK,EAELC,YAFK,EAGLC,UAHK,EAILC,UAJK,EAKLC,UALK,EAMLC,MANK,EAOLC,KAPK,EAQuB;AAC5B,QAAMC,oBAAoB,GAAIC,YAAD,IAAkBC,gBAAKC,OAAL,CAAaT,YAAb,EAA2BO,YAA3B,CAA/C,CAD4B,CAG5B;;;AACAZ,EAAAA,OAAO,CAACC,GAAR,CAAYC,QAAZ,GAAuB,aAAvB;AAEA,QAAMa,eAAe,GAAI,GAAER,UAAW,IAAGC,UAAW,EAApD;AAEA,SAAO;AACL;AACAQ,IAAAA,IAAI,EAAE,aAFD;AAILC,IAAAA,OAAO,EAAE,mBAJJ;AAML;AACAC,IAAAA,KAAK,EAAEZ,UAAU,CAACa,GAAX,CAAgBC,QAAD,IAAcT,oBAAoB,CAACS,QAAD,CAAjD,CAPF;AASLC,IAAAA,MAAM,EAAE;AACN;AACAC,MAAAA,QAAQ,EAAE,4BAFJ;AAINC,MAAAA,QAAQ,EAAE,IAJJ;AAMNV,MAAAA,IAAI,EAAEF,oBAAoB,CAACI,eAAD,CANpB;AAQN;AAEAS,MAAAA,aAAa,EAAE,2BAVT;AAYN;AACAC,MAAAA,6BAA6B,EAAGC,IAAD,IAAU,mCAAqBb,gBAAKC,OAAL,CAAaY,IAAI,CAACC,oBAAlB,CAArB,CAbnC,CAeN;AACA;AACA;AACA;;AAlBM,KATH;AA8BLC,IAAAA,qBAAqB,EAAE;AACrBC,MAAAA,KAAK,EAAE;AADc,KA9BlB;AAkCLC,IAAAA,KAAK,EAAE,
|
|
1
|
+
{"version":3,"sources":["webpack.dev.config.ts"],"names":["publicUrlOrPath","process","env","NODE_ENV","configFactory","devServerID","workspaceDir","entryFiles","publicRoot","publicPath","pubsub","title","resolveWorkspacePath","relativePath","path","resolve","publicDirectory","mode","devtool","entry","map","filePath","output","filename","pathinfo","chunkFilename","devtoolModuleFilenameTemplate","info","absoluteResourcePath","infrastructureLogging","level","stats","errorDetails","devServer","allowedHosts","static","directory","staticOptions","serveIndex","watch","compress","hot","historyApiFallback","disableDotRule","index","client","overlay","onBeforeSetupMiddleware","app","server","use","onAfterSetupMiddleware","devMiddleware","join","extensions","alias","fallbacksAliases","fallback","fallbacks","plugins","HtmlWebpackPlugin","templateContent","webpack","ProvidePlugin","fallbacksProvidePluginConfig","WebpackBitReporterPlugin","options"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA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KvC;;AACAD,QAAAA,GAAG,CAACE,GAAJ,CAAQ,wCAAR;AACD,OA1CQ;;AA4CTC,MAAAA,sBAAsB,CAAC;AAAEH,QAAAA;AAAF,OAAD,EAAU;AAC9B;AACAA,QAAAA,GAAG,CAACE,GAAJ,CAAQ,6CAAmBlD,eAAnB,CAAR,EAF8B,CAI9B;AACA;AACA;AACA;AACA;;AACAgD,QAAAA,GAAG,CAACE,GAAJ,CAAQ,4CAA4BlD,eAA5B,CAAR;AACD,OAtDQ;;AAwDToD,MAAAA,aAAa,EAAE;AACb;AACA3C,QAAAA,UAAU,EAAEK,gBAAKuC,IAAL,CAAU,GAAV,EAAe7C,UAAf;AAFC;AAxDN,KAtCN;AAoGLO,IAAAA,OAAO,EAAE;AACPuC,MAAAA,UAAU,EAAE,CAAC,KAAD,EAAQ,MAAR,EAAgB,KAAhB,EAAuB,MAAvB,EAA+B,KAA/B,CADL;AAEPC,MAAAA,KAAK,EAAEC,2CAFA;AAIPC,MAAAA,QAAQ,EAAEC;AAJH,KApGJ;AA2GLC,IAAAA,OAAO,EAAE,CACP,KAAIC,4BAAJ,EAAsB;AACpBC,MAAAA,eAAe,EAAE,kBAAKlD,KAAK,IAAI,mBAAd,CADG;AAEpBY,MAAAA,QAAQ,EAAE;AAFU,KAAtB,CADO,EAMP,KAAIuC,mBAAQC,aAAZ,EAA0BC,mEAA1B,CANO,EAQP,KAAIC,oDAAJ,EAA6B;AAC3BC,MAAAA,OAAO,EAAE;AAAExD,QAAAA,MAAF;AAAUL,QAAAA;AAAV;AADkB,KAA7B,CARO;AA3GJ,GAAP;AAwHD","sourcesContent":["import path from 'path';\nimport webpack from 'webpack';\nimport HtmlWebpackPlugin from 'html-webpack-plugin';\nimport errorOverlayMiddleware from 'react-dev-utils/errorOverlayMiddleware';\nimport evalSourceMapMiddleware from 'react-dev-utils/evalSourceMapMiddleware';\nimport noopServiceWorkerMiddleware from 'react-dev-utils/noopServiceWorkerMiddleware';\nimport redirectServedPath from 'react-dev-utils/redirectServedPathMiddleware';\nimport getPublicUrlOrPath from 'react-dev-utils/getPublicUrlOrPath';\nimport { PubsubMain } from '@teambit/pubsub';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { WebpackConfigWithDevServer } from '../webpack.dev-server';\nimport { fallbacks } from './webpack-fallbacks';\n\nimport { html } from './html';\n\nimport { WebpackBitReporterPlugin } from '../plugins/webpack-bit-reporter-plugin';\nimport { fallbacksProvidePluginConfig } from './webpack-fallbacks-provide-plugin-config';\nimport { fallbacksAliases } from './webpack-fallbacks-aliases';\n\nconst publicUrlOrPath = getPublicUrlOrPath(process.env.NODE_ENV === 'development', '/', '/public');\n\nexport function configFactory(\n devServerID: string,\n workspaceDir: string,\n entryFiles: string[],\n publicRoot: string,\n publicPath: string,\n pubsub: PubsubMain,\n title?: string\n): WebpackConfigWithDevServer {\n const resolveWorkspacePath = (relativePath) => path.resolve(workspaceDir, relativePath);\n\n // Required for babel-preset-react-app\n process.env.NODE_ENV = 'development';\n\n const publicDirectory = `${publicRoot}/${publicPath}`;\n\n return {\n // Environment mode\n mode: 'development',\n\n devtool: 'inline-source-map',\n\n // Entry point of app\n entry: entryFiles.map((filePath) => resolveWorkspacePath(filePath)),\n\n output: {\n // Development filename output\n filename: 'static/js/[name].bundle.js',\n\n pathinfo: true,\n\n path: resolveWorkspacePath(publicDirectory),\n\n // publicPath: resolveWorkspacePath(publicDirectory),\n\n chunkFilename: 'static/js/[name].chunk.js',\n\n // point sourcemap entries to original disk locations (format as URL on windows)\n devtoolModuleFilenameTemplate: (info) => pathNormalizeToLinux(path.resolve(info.absoluteResourcePath)),\n\n // this defaults to 'window', but by setting it to 'this' then\n // module chunks which are built will work in web workers as well.\n // Commented out to use the default (self) as according to tobias with webpack5 self is working with workers as well\n // globalObject: 'this',\n },\n\n infrastructureLogging: {\n level: 'error',\n },\n\n stats: {\n errorDetails: true,\n },\n\n devServer: {\n allowedHosts: 'all',\n\n static: [\n {\n directory: resolveWorkspacePath(publicDirectory),\n staticOptions: {},\n // Don't be confused with `dev.publicPath`, it is `publicPath` for static directory\n // Can be:\n // publicPath: ['/static-public-path-one/', '/static-public-path-two/'],\n publicPath: publicDirectory,\n // Can be:\n // serveIndex: {} (options for the `serveIndex` option you can find https://github.com/expressjs/serve-index)\n serveIndex: true,\n // Can be:\n // watch: {} (options for the `watch` option you can find https://github.com/paulmillr/chokidar)\n watch: true,\n },\n ],\n\n // Enable compression\n compress: true,\n\n // Enable hot reloading\n hot: true,\n\n historyApiFallback: {\n disableDotRule: true,\n index: resolveWorkspacePath(publicDirectory),\n },\n\n client: {\n overlay: false,\n },\n\n onBeforeSetupMiddleware({ app, server }) {\n // Keep `evalSourceMapMiddleware` and `errorOverlayMiddleware`\n // middlewares before `redirectServedPath` otherwise will not have any effect\n // This lets us fetch source contents from webpack for the error overlay\n app.use(evalSourceMapMiddleware(server));\n // This lets us open files from the runtime error overlay.\n app.use(errorOverlayMiddleware());\n },\n\n onAfterSetupMiddleware({ app }) {\n // Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match\n app.use(redirectServedPath(publicUrlOrPath));\n\n // This service worker file is effectively a 'no-op' that will reset any\n // previous service worker registered for the same host:port combination.\n // We do this in development to avoid hitting the production cache if\n // it used the same host and port.\n // https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432\n app.use(noopServiceWorkerMiddleware(publicUrlOrPath));\n },\n\n devMiddleware: {\n // forward static files\n publicPath: path.join('/', publicRoot),\n },\n },\n\n resolve: {\n extensions: ['.ts', '.tsx', '.js', '.mdx', '.md'],\n alias: fallbacksAliases,\n\n fallback: fallbacks as any,\n },\n\n plugins: [\n new HtmlWebpackPlugin({\n templateContent: html(title || 'Component preview'),\n filename: 'index.html',\n }),\n\n new webpack.ProvidePlugin(fallbacksProvidePluginConfig),\n\n new WebpackBitReporterPlugin({\n options: { pubsub, devServerID },\n }),\n ],\n };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Bundler, BundlerResult, Target } from '@teambit/bundler';
|
|
2
|
-
import { Logger } from '@teambit/logger';
|
|
3
|
-
import { Configuration } from 'webpack';
|
|
1
|
+
import type { Bundler, BundlerResult, Target } from '@teambit/bundler';
|
|
2
|
+
import type { Logger } from '@teambit/logger';
|
|
3
|
+
import type { Configuration } from 'webpack';
|
|
4
4
|
export declare class WebpackBundler implements Bundler {
|
|
5
5
|
/**
|
|
6
6
|
* targets to bundle.
|
|
@@ -22,5 +22,6 @@ export declare class WebpackBundler implements Bundler {
|
|
|
22
22
|
*/
|
|
23
23
|
configs: Configuration[], logger: Logger, webpack: any);
|
|
24
24
|
run(): Promise<BundlerResult[]>;
|
|
25
|
+
private getAssets;
|
|
25
26
|
private getComponents;
|
|
26
27
|
}
|
package/dist/webpack.bundler.js
CHANGED
|
@@ -59,6 +59,7 @@ class WebpackBundler {
|
|
|
59
59
|
// @see https://github.com/trivago/parallel-webpack
|
|
60
60
|
return compiler.run((err, stats) => {
|
|
61
61
|
if (err) {
|
|
62
|
+
this.logger.error('get error from webpack compiler, full error:', err);
|
|
62
63
|
return resolve({
|
|
63
64
|
errors: [`${err.toString()}\n${err.stack}`],
|
|
64
65
|
components
|
|
@@ -68,6 +69,9 @@ class WebpackBundler {
|
|
|
68
69
|
if (!stats) throw new (_bitError().BitError)('unknown build error');
|
|
69
70
|
const info = stats.toJson();
|
|
70
71
|
return resolve({
|
|
72
|
+
assets: this.getAssets(info),
|
|
73
|
+
assetsByChunkName: info.assetsByChunkName,
|
|
74
|
+
entriesAssetsMap: info.entrypoints,
|
|
71
75
|
errors: info.errors,
|
|
72
76
|
outputPath: stats.compilation.outputOptions.path,
|
|
73
77
|
components,
|
|
@@ -82,6 +86,16 @@ class WebpackBundler {
|
|
|
82
86
|
return componentOutput;
|
|
83
87
|
}
|
|
84
88
|
|
|
89
|
+
getAssets(stats) {
|
|
90
|
+
if (!stats.assets) return [];
|
|
91
|
+
return stats.assets.map(asset => {
|
|
92
|
+
return {
|
|
93
|
+
name: asset.name,
|
|
94
|
+
size: asset.size
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
85
99
|
getComponents(outputPath) {
|
|
86
100
|
const splitPath = outputPath.split('/');
|
|
87
101
|
splitPath.pop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack.bundler.ts"],"names":["WebpackBundler","constructor","targets","configs","logger","webpack","run","startTime","Date","now","compilers","map","config","longProcessLogger","createLongProcessLogger","length","componentOutput","compiler","components","getComponents","outputPath","logProgress","component","id","toString","join","Promise","resolve","err","stats","errors","stack","BitError","info","toJson","compilation","outputOptions","path","warnings","endTime","end","splitPath","split","pop","target","find","targetCandidate","Error"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,cAAN,CAAwC;AAC7CC,EAAAA,WAAW;AACT;AACJ;AACA;AACYC,EAAAA,OAJC;AAMT;AACJ;AACA;AACYC,EAAAA,OATC,EAWDC,MAXC,EAaDC,OAbC,EAcT;AAAA,SAVQH,OAUR,GAVQA,OAUR;AAAA,SALQC,OAKR,GALQA,OAKR;AAAA,SAHQC,MAGR,GAHQA,MAGR;AAAA,SADQC,OACR,GADQA,OACR;AAAE;;AAEK,QAAHC,GAAG,GAA6B;AACpC,UAAMC,SAAS,GAAGC,IAAI,CAACC,GAAL,EAAlB;AACA,UAAMC,SAAS,GAAG,KAAKP,OAAL,CAAaQ,GAAb,CAAkBC,MAAD,IAAiB,KAAKP,OAAL,CAAaO,MAAb,CAAlC,CAAlB;AACA,UAAMC,iBAAiB,GAAG,KAAKT,MAAL,CAAYU,uBAAZ,CAAoC,yBAApC,EAA+DJ,SAAS,CAACK,MAAzE,CAA1B;AACA,UAAMC,eAAe,GAAG,MAAM,2BAAUN,SAAV,EAAsBO,QAAD,IAAwB;AACzE,YAAMC,UAAU,GAAG,KAAKC,aAAL,CAAmBF,QAAQ,CAACG,UAA5B,CAAnB;AACAP,MAAAA,iBAAiB,CAACQ,WAAlB,CAA8BH,UAAU,CAACP,GAAX,CAAgBW,SAAD,IAAeA,SAAS,CAACC,EAAV,CAAaC,QAAb,EAA9B,EAAuDC,IAAvD,CAA4D,IAA5D,CAA9B;AACA,aAAO,IAAIC,OAAJ,CAAaC,OAAD,IAAa;AAC9B;AACA;AACA,eAAOV,QAAQ,CAACX,GAAT,CAAa,CAACsB,GAAD,EAAMC,KAAN,KAAgB;AAClC,cAAID,GAAJ,EAAS;AACP,mBAAOD,OAAO,CAAC;
|
|
1
|
+
{"version":3,"sources":["webpack.bundler.ts"],"names":["WebpackBundler","constructor","targets","configs","logger","webpack","run","startTime","Date","now","compilers","map","config","longProcessLogger","createLongProcessLogger","length","componentOutput","compiler","components","getComponents","outputPath","logProgress","component","id","toString","join","Promise","resolve","err","stats","error","errors","stack","BitError","info","toJson","assets","getAssets","assetsByChunkName","entriesAssetsMap","entrypoints","compilation","outputOptions","path","warnings","endTime","end","asset","name","size","splitPath","split","pop","target","find","targetCandidate","Error"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,cAAN,CAAwC;AAC7CC,EAAAA,WAAW;AACT;AACJ;AACA;AACYC,EAAAA,OAJC;AAMT;AACJ;AACA;AACYC,EAAAA,OATC,EAWDC,MAXC,EAaDC,OAbC,EAcT;AAAA,SAVQH,OAUR,GAVQA,OAUR;AAAA,SALQC,OAKR,GALQA,OAKR;AAAA,SAHQC,MAGR,GAHQA,MAGR;AAAA,SADQC,OACR,GADQA,OACR;AAAE;;AAEK,QAAHC,GAAG,GAA6B;AACpC,UAAMC,SAAS,GAAGC,IAAI,CAACC,GAAL,EAAlB;AACA,UAAMC,SAAS,GAAG,KAAKP,OAAL,CAAaQ,GAAb,CAAkBC,MAAD,IAAi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kBC,aAAlB,CAAgCC,IAL/B;AAMbzB,YAAAA,UANa;AAOb0B,YAAAA,QAAQ,EAAEV,IAAI,CAACU,QAPF;AAQbrC,YAAAA,SARa;AASbsC,YAAAA,OAAO,EAAErC,IAAI,CAACC,GAAL;AATI,WAAD,CAAd;AAWD,SAvBM,CAAP;AAwBD,OA3BM,CAAP;AA4BD,KA/B6B,CAA9B;AAgCAI,IAAAA,iBAAiB,CAACiC,GAAlB;AACA,WAAO9B,eAAP;AACD;;AAEOqB,EAAAA,SAAS,CAACR,KAAD,EAAmC;AAClD,QAAI,CAACA,KAAK,CAACO,MAAX,EAAmB,OAAO,EAAP;AACnB,WAAOP,KAAK,CAACO,MAAN,CAAazB,GAAb,CAAkBoC,KAAD,IAAW;AACjC,aAAO;AACLC,QAAAA,IAAI,EAAED,KAAK,CAACC,IADP;AAELC,QAAAA,IAAI,EAAEF,KAAK,CAACE;AAFP,OAAP;AAID,KALM,CAAP;AAMD;;AAEO9B,EAAAA,aAAa,CAACC,UAAD,EAAqB;AACxC,UAAM8B,SAAS,GAAG9B,UAAU,CAAC+B,KAAX,CAAiB,GAAjB,CAAlB;AACAD,IAAAA,SAAS,CAACE,GAAV;AACA,UAAMT,IAAI,GAAGO,SAAS,CAACzB,IAAV,CAAe,GAAf,CAAb;AACA,UAAM4B,MAAM,GAAG,KAAKnD,OAAL,CAAaoD,IAAb,CAAmBC,eAAD,IAAqB;AACpD,aAAOZ,IAAI,KAAKY,eAAe,CAACnC,UAAhC;AACD,KAFc,CAAf;;AAIA,QAAI,CAACiC,MAAL,EAAa;AACX,YAAM,IAAIG,KAAJ,CAAW,yCAAwCb,IAAK,GAAxD,CAAN;AACD;;AAED,WAAOU,MAAM,CAACnC,UAAd;AACD;;AAhF4C","sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport type { Bundler, BundlerResult, Asset, Target } from '@teambit/bundler';\nimport type { Logger } from '@teambit/logger';\nimport mapSeries from 'p-map-series';\nimport type { Compiler, Configuration, StatsCompilation } from 'webpack';\n\nexport class WebpackBundler implements Bundler {\n constructor(\n /**\n * targets to bundle.\n */\n private targets: Target[],\n\n /**\n * webpack configuration.\n */\n private configs: Configuration[],\n\n private logger: Logger,\n\n private webpack\n ) {}\n\n async run(): Promise<BundlerResult[]> {\n const startTime = Date.now();\n const compilers = this.configs.map((config: any) => this.webpack(config));\n const longProcessLogger = this.logger.createLongProcessLogger('running Webpack bundler', compilers.length);\n const componentOutput = await mapSeries(compilers, (compiler: Compiler) => {\n const components = this.getComponents(compiler.outputPath);\n longProcessLogger.logProgress(components.map((component) => component.id.toString()).join(', '));\n return new Promise((resolve) => {\n // TODO: split to multiple processes to reduce time and configure concurrent builds.\n // @see https://github.com/trivago/parallel-webpack\n return compiler.run((err, stats) => {\n if (err) {\n this.logger.error('get error from webpack compiler, full error:', err);\n\n return resolve({\n errors: [`${err.toString()}\\n${err.stack}`],\n components,\n });\n }\n if (!stats) throw new BitError('unknown build error');\n const info = stats.toJson();\n\n return resolve({\n assets: this.getAssets(info),\n assetsByChunkName: info.assetsByChunkName,\n entriesAssetsMap: info.entrypoints,\n errors: info.errors,\n outputPath: stats.compilation.outputOptions.path,\n components,\n warnings: info.warnings,\n startTime,\n endTime: Date.now(),\n });\n });\n });\n });\n longProcessLogger.end();\n return componentOutput as BundlerResult[];\n }\n\n private getAssets(stats: StatsCompilation): Asset[] {\n if (!stats.assets) return [];\n return stats.assets.map((asset) => {\n return {\n name: asset.name,\n size: asset.size,\n };\n });\n }\n\n private getComponents(outputPath: string) {\n const splitPath = outputPath.split('/');\n splitPath.pop();\n const path = splitPath.join('/');\n const target = this.targets.find((targetCandidate) => {\n return path === targetCandidate.outputPath;\n });\n\n if (!target) {\n throw new Error(`Could not find component id for path \"${path}\"`);\n }\n\n return target.components;\n }\n}\n"]}
|
|
@@ -54,10 +54,7 @@ export declare class WebpackMain {
|
|
|
54
54
|
createDevServer(context: DevServerContext, transformers?: WebpackConfigTransformer[]): DevServer;
|
|
55
55
|
mergeConfig(target: any, source: any): any;
|
|
56
56
|
createBundler(context: BundlerContext, transformers?: WebpackConfigTransformer[], initialConfigs?: webpack.Configuration[]): WebpackBundler;
|
|
57
|
-
createPreviewBundler(context: BundlerContext, transformers?: WebpackConfigTransformer[]): WebpackBundler;
|
|
58
57
|
private createConfigs;
|
|
59
|
-
private createEmptyConfigs;
|
|
60
|
-
private createPreviewConfig;
|
|
61
58
|
private createDevServerConfig;
|
|
62
59
|
static slots: never[];
|
|
63
60
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
@@ -122,16 +122,6 @@ function _webpackDev() {
|
|
|
122
122
|
return data;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
function _webpackPreview() {
|
|
126
|
-
const data = require("./config/webpack-preview.config");
|
|
127
|
-
|
|
128
|
-
_webpackPreview = function () {
|
|
129
|
-
return data;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
return data;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
125
|
function _webpack2() {
|
|
136
126
|
const data = require("./config/webpack.config");
|
|
137
127
|
|
|
@@ -218,22 +208,15 @@ class WebpackMain {
|
|
|
218
208
|
createBundler(context, transformers = [], initialConfigs) {
|
|
219
209
|
const transformerContext = {
|
|
220
210
|
mode: 'prod'
|
|
221
|
-
};
|
|
222
|
-
const configs = initialConfigs || this.createEmptyConfigs(context.targets, transformers, transformerContext);
|
|
223
|
-
return new (_webpack4().WebpackBundler)(context.targets, configs, this.logger, _webpack().default);
|
|
224
|
-
}
|
|
211
|
+
}; // eslint-disable-next-line max-len
|
|
225
212
|
|
|
226
|
-
|
|
227
|
-
const transformerContext = {
|
|
228
|
-
mode: 'prod'
|
|
229
|
-
};
|
|
230
|
-
const configs = this.createPreviewConfig(context.targets, transformers, transformerContext);
|
|
213
|
+
const configs = initialConfigs || this.createConfigs(context.targets, _webpack2().configFactory, transformers, transformerContext, context);
|
|
231
214
|
return new (_webpack4().WebpackBundler)(context.targets, configs, this.logger, _webpack().default);
|
|
232
215
|
}
|
|
233
216
|
|
|
234
|
-
createConfigs(targets, factory, transformers = [], transformerContext) {
|
|
217
|
+
createConfigs(targets, factory, transformers = [], transformerContext, bundlerContext) {
|
|
235
218
|
return targets.map(target => {
|
|
236
|
-
const baseConfig = factory(target
|
|
219
|
+
const baseConfig = factory(target, bundlerContext);
|
|
237
220
|
const configMutator = new (_webpackModules().WebpackConfigMutator)(baseConfig);
|
|
238
221
|
const context = Object.assign({}, transformerContext, {
|
|
239
222
|
target
|
|
@@ -243,14 +226,6 @@ class WebpackMain {
|
|
|
243
226
|
});
|
|
244
227
|
}
|
|
245
228
|
|
|
246
|
-
createEmptyConfigs(targets, transformers = [], transformerContext) {
|
|
247
|
-
return this.createConfigs(targets, _webpack2().configFactory, transformers, transformerContext);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
createPreviewConfig(targets, transformers = [], transformerContext) {
|
|
251
|
-
return this.createConfigs(targets, _webpackPreview().previewConfigFactory, transformers, transformerContext);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
229
|
createDevServerConfig(entry, rootPath, devServerID, publicRoot, publicPath, title) {
|
|
255
230
|
return (0, _webpackDev().configFactory)(devServerID, rootPath, entry, publicRoot, publicPath, this.pubsub, title);
|
|
256
231
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack.main.runtime.ts"],"names":["WebpackMain","constructor","pubsub","workspace","bundler","logger","createDevServer","context","transformers","config","createDevServerConfig","entry","path","id","rootPath","publicPath","title","configMutator","WebpackConfigMutator","transformerContext","mode","afterMutation","runTransformersWithContext","clone","WebpackDevServer","raw","webpack","WsDevServer","mergeConfig","target","source","createBundler","initialConfigs","configs","createEmptyConfigs","targets","WebpackBundler","createPreviewBundler","createPreviewConfig","createConfigs","factory","map","baseConfig","entries","outputPath","Object","assign","baseConfigFactory","previewConfigFactory","devServerID","publicRoot","provider","logPublisher","createLogger","WebpackAspect","MainRuntime","PubsubAspect","WorkspaceAspect","BundlerAspect","Logg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AO3B;AACA,WAAO,iCAAuBiC,WAAvB,EAAoCnC,QAApC,EAA8CH,KAA9C,EAAqDuC,UAArD,EAAiEnC,UAAjE,EAA6E,KAAKb,MAAlF,EAA0Fc,KAA1F,CAAP;AACD;;AAOoB,eAARmC,QAAQ,CAAC,CAACjD,MAAD,EAASC,SAAT,EAAoBC,OAApB,EAA6BC,MAA7B,CAAD,EAAyF;AAC5G,UAAM+C,YAAY,GAAG/C,MAAM,CAACgD,YAAP,CAAoBC,0BAAczC,EAAlC,CAArB;AACA,WAAO,IAAIb,WAAJ,CAAgBE,MAAhB,EAAwBC,SAAxB,EAAmCC,OAAnC,EAA4CgD,YAA5C,CAAP;AACD;;AAhHsB;;;gCAAZpD,W,WAwGI,E;gCAxGJA,W,aA0GMuD,kB;gCA1GNvD,W,kBA2GW,CAACwD,iBAAD,EAAeC,4BAAf,EAAgCC,wBAAhC,EAA+CC,sBAA/C,C;;AAQxBL,0BAAcM,UAAd,CAAyB5D,WAAzB;;AAEO,SAASsB,0BAAT,CACLb,MADK,EAELD,YAAiF,GAAG,EAF/E,EAGLD,OAHK,EAIiB;AACtB,MAAI,CAACsD,KAAK,CAACC,OAAN,CAActD,YAAd,CAAL,EAAkC,OAAOC,MAAP;AAClC,QAAMsD,SAAS,GAAGvD,YAAY,CAACwD,MAAb,CAAoB,CAACC,GAAD,EAAMC,WAAN,KAAsB;AAC1D;AACA,WAAOA,WAAW,CAACD,GAAD,EAAM1D,OAAN,CAAlB;AACD,GAHiB,EAGfE,MAHe,CAAlB;AAIA,SAAOsD,SAAP;AACD","sourcesContent":["import webpack, { Configuration } from 'webpack';\nimport PubsubAspect, { PubsubMain } from '@teambit/pubsub';\nimport {\n BundlerAspect,\n BundlerContext,\n BundlerMain,\n DevServer,\n DevServerContext,\n BundlerMode,\n Target,\n} from '@teambit/bundler';\nimport { MainRuntime } from '@teambit/cli';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport { merge } from 'webpack-merge';\nimport WsDevServer from 'webpack-dev-server';\nimport { WebpackConfigMutator } from '@teambit/webpack.modules.config-mutator';\n\nimport { configFactory as devServerConfigFactory } from './config/webpack.dev.config';\nimport { previewConfigFactory } from './config/webpack-preview.config';\nimport { configFactory as baseConfigFactory } from './config/webpack.config';\n\nimport { WebpackAspect } from './webpack.aspect';\nimport { WebpackBundler } from './webpack.bundler';\nimport { WebpackDevServer } from './webpack.dev-server';\n\nexport type WebpackConfigTransformContext = GlobalWebpackConfigTransformContext & {\n target: Target;\n};\n\nexport type WebpackConfigDevServerTransformContext = GlobalWebpackConfigTransformContext;\n\nexport type GlobalWebpackConfigTransformContext = {\n mode: BundlerMode;\n};\n\nexport type WebpackConfigTransformer = (\n config: WebpackConfigMutator,\n context: WebpackConfigTransformContext\n) => WebpackConfigMutator;\n\nexport type WebpackConfigDevServerTransformer = (\n config: WebpackConfigMutator,\n context: WebpackConfigDevServerTransformContext\n) => WebpackConfigMutator;\n\nexport class WebpackMain {\n constructor(\n /**\n * Pubsub extension.\n */\n public pubsub: PubsubMain,\n\n /**\n * workspace extension.\n */\n private workspace: Workspace,\n\n /**\n * bundler extension.\n */\n private bundler: BundlerMain,\n\n /**\n * Logger extension\n */\n public logger: Logger\n ) {}\n\n /**\n * create an instance of bit-compliant webpack dev server for a set of components\n */\n createDevServer(context: DevServerContext, transformers: WebpackConfigTransformer[] = []): DevServer {\n const config = this.createDevServerConfig(\n context.entry,\n this.workspace.path,\n context.id,\n context.rootPath,\n context.publicPath,\n context.title\n ) as any;\n const configMutator = new WebpackConfigMutator(config);\n const transformerContext: GlobalWebpackConfigTransformContext = { mode: 'dev' };\n const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext);\n // @ts-ignore - fix this\n return new WebpackDevServer(afterMutation.raw, webpack, WsDevServer);\n }\n\n mergeConfig(target: any, source: any): any {\n return merge(target, source);\n }\n\n createBundler(\n context: BundlerContext,\n transformers: WebpackConfigTransformer[] = [],\n initialConfigs?: webpack.Configuration[]\n ) {\n const transformerContext: GlobalWebpackConfigTransformContext = { mode: 'prod' };\n const configs = initialConfigs || this.createEmptyConfigs(context.targets, transformers, transformerContext);\n return new WebpackBundler(context.targets, configs, this.logger, webpack);\n }\n\n createPreviewBundler(context: BundlerContext, transformers: WebpackConfigTransformer[] = []) {\n const transformerContext: GlobalWebpackConfigTransformContext = { mode: 'prod' };\n const configs = this.createPreviewConfig(context.targets, transformers, transformerContext);\n return new WebpackBundler(context.targets, configs, this.logger, webpack);\n }\n\n private createConfigs(\n targets: Target[],\n factory: (entries: string[], outputPath: string) => Configuration,\n transformers: WebpackConfigTransformer[] = [],\n transformerContext: GlobalWebpackConfigTransformContext\n ) {\n return targets.map((target) => {\n const baseConfig = factory(target.entries, target.outputPath);\n const configMutator = new WebpackConfigMutator(baseConfig);\n const context = Object.assign({}, transformerContext, { target });\n const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, context);\n return afterMutation.raw;\n });\n }\n\n private createEmptyConfigs(\n targets: Target[],\n transformers: WebpackConfigTransformer[] = [],\n transformerContext: GlobalWebpackConfigTransformContext\n ) {\n return this.createConfigs(targets, baseConfigFactory, transformers, transformerContext);\n }\n\n private createPreviewConfig(\n targets: Target[],\n transformers: WebpackConfigTransformer[] = [],\n transformerContext: GlobalWebpackConfigTransformContext\n ) {\n return this.createConfigs(targets, previewConfigFactory, transformers, transformerContext);\n }\n\n private createDevServerConfig(\n entry: string[],\n rootPath: string,\n devServerID: string,\n publicRoot: string,\n publicPath: string,\n title?: string\n ) {\n return devServerConfigFactory(devServerID, rootPath, entry, publicRoot, publicPath, this.pubsub, title);\n }\n\n static slots = [];\n\n static runtime = MainRuntime;\n static dependencies = [PubsubAspect, WorkspaceAspect, BundlerAspect, LoggerAspect];\n\n static async provider([pubsub, workspace, bundler, logger]: [PubsubMain, Workspace, BundlerMain, LoggerMain]) {\n const logPublisher = logger.createLogger(WebpackAspect.id);\n return new WebpackMain(pubsub, workspace, bundler, logPublisher);\n }\n}\n\nWebpackAspect.addRuntime(WebpackMain);\n\nexport function runTransformersWithContext(\n config: WebpackConfigMutator,\n transformers: Array<WebpackConfigTransformer | WebpackConfigDevServerTransformer> = [],\n context: WebpackConfigTransformContext | WebpackConfigDevServerTransformContext\n): WebpackConfigMutator {\n if (!Array.isArray(transformers)) return config;\n const newConfig = transformers.reduce((acc, transformer) => {\n // @ts-ignore\n return transformer(acc, context);\n }, config);\n return newConfig;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["webpack.main.runtime.ts"],"names":["WebpackMain","constructor","pubsub","workspace","bundler","logger","createDevServer","context","transformers","config","createDevServerConfig","entry","path","id","rootPath","publicPath","title","configMutator","WebpackConfigMutator","transformerContext","mode","afterMutation","runTransformersWithContext","clone","WebpackDevServer","raw","webpack","WsDevServer","mergeConfig","target","source","createBundler","initialConfigs","configs","createConfigs","targets","baseConfigFactory","WebpackBundler","factory","bundlerContext","map","baseConfig","Object","assign","devServerID","publicRoot","provider","logPublisher","createLogger","WebpackAspect","MainRuntime","PubsubAspect","WorkspaceAspect","BundlerAspect","LoggerAspect","addRuntime","Array","isArray","newConfig","reduce","acc","transformer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AASA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA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6E,KAAKb,MAAlF,EAA0Fc,KAA1F,CAAP;AACD;;AAOoB,eAAR8B,QAAQ,CAAC,CAAC5C,MAAD,EAASC,SAAT,EAAoBC,OAApB,EAA6BC,MAA7B,CAAD,EAAyF;AAC5G,UAAM0C,YAAY,GAAG1C,MAAM,CAAC2C,YAAP,CAAoBC,0BAAcpC,EAAlC,CAArB;AACA,WAAO,IAAIb,WAAJ,CAAgBE,MAAhB,EAAwBC,SAAxB,EAAmCC,OAAnC,EAA4C2C,YAA5C,CAAP;AACD;;AA9FsB;;;gCAAZ/C,W,WAsFI,E;gCAtFJA,W,aAwFMkD,kB;gCAxFNlD,W,kBAyFW,CAACmD,iBAAD,EAAeC,4BAAf,EAAgCC,wBAAhC,EAA+CC,sBAA/C,C;;AAQxBL,0BAAcM,UAAd,CAAyBvD,WAAzB;;AAEO,SAASsB,0BAAT,CACLb,MADK,EAELD,YAAiF,GAAG,EAF/E,EAGLD,OAHK,EAIiB;AACtB,MAAI,CAACiD,KAAK,CAACC,OAAN,CAAcjD,YAAd,CAAL,EAAkC,OAAOC,MAAP;AAClC,QAAMiD,SAAS,GAAGlD,YAAY,CAACmD,MAAb,CAAoB,CAACC,GAAD,EAAMC,WAAN,KAAsB;AAC1D;AACA,WAAOA,WAAW,CAACD,GAAD,EAAMrD,OAAN,CAAlB;AACD,GAHiB,EAGfE,MAHe,CAAlB;AAIA,SAAOiD,SAAP;AACD","sourcesContent":["import webpack, { Configuration } from 'webpack';\nimport PubsubAspect, { PubsubMain } from '@teambit/pubsub';\nimport {\n BundlerAspect,\n BundlerContext,\n BundlerMain,\n DevServer,\n DevServerContext,\n BundlerMode,\n Target,\n} from '@teambit/bundler';\nimport { MainRuntime } from '@teambit/cli';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport { merge } from 'webpack-merge';\nimport WsDevServer from 'webpack-dev-server';\nimport { WebpackConfigMutator } from '@teambit/webpack.modules.config-mutator';\n\nimport { configFactory as devServerConfigFactory } from './config/webpack.dev.config';\nimport { configFactory as baseConfigFactory } from './config/webpack.config';\n\nimport { WebpackAspect } from './webpack.aspect';\nimport { WebpackBundler } from './webpack.bundler';\nimport { WebpackDevServer } from './webpack.dev-server';\n\nexport type WebpackConfigTransformContext = GlobalWebpackConfigTransformContext & {\n target: Target;\n};\n\nexport type WebpackConfigDevServerTransformContext = GlobalWebpackConfigTransformContext;\n\nexport type GlobalWebpackConfigTransformContext = {\n mode: BundlerMode;\n};\n\nexport type WebpackConfigTransformer = (\n config: WebpackConfigMutator,\n context: WebpackConfigTransformContext\n) => WebpackConfigMutator;\n\nexport type WebpackConfigDevServerTransformer = (\n config: WebpackConfigMutator,\n context: WebpackConfigDevServerTransformContext\n) => WebpackConfigMutator;\n\nexport class WebpackMain {\n constructor(\n /**\n * Pubsub extension.\n */\n public pubsub: PubsubMain,\n\n /**\n * workspace extension.\n */\n private workspace: Workspace,\n\n /**\n * bundler extension.\n */\n private bundler: BundlerMain,\n\n /**\n * Logger extension\n */\n public logger: Logger\n ) {}\n\n /**\n * create an instance of bit-compliant webpack dev server for a set of components\n */\n createDevServer(context: DevServerContext, transformers: WebpackConfigTransformer[] = []): DevServer {\n const config = this.createDevServerConfig(\n context.entry,\n this.workspace.path,\n context.id,\n context.rootPath,\n context.publicPath,\n context.title\n ) as any;\n const configMutator = new WebpackConfigMutator(config);\n const transformerContext: GlobalWebpackConfigTransformContext = { mode: 'dev' };\n const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext);\n // @ts-ignore - fix this\n return new WebpackDevServer(afterMutation.raw, webpack, WsDevServer);\n }\n\n mergeConfig(target: any, source: any): any {\n return merge(target, source);\n }\n\n createBundler(\n context: BundlerContext,\n transformers: WebpackConfigTransformer[] = [],\n initialConfigs?: webpack.Configuration[]\n ) {\n const transformerContext: GlobalWebpackConfigTransformContext = { mode: 'prod' };\n // eslint-disable-next-line max-len\n const configs =\n initialConfigs ||\n this.createConfigs(context.targets, baseConfigFactory, transformers, transformerContext, context);\n return new WebpackBundler(context.targets, configs, this.logger, webpack);\n }\n\n private createConfigs(\n targets: Target[],\n factory: (target: Target, context: BundlerContext) => Configuration,\n transformers: WebpackConfigTransformer[] = [],\n transformerContext: GlobalWebpackConfigTransformContext,\n bundlerContext: BundlerContext\n ) {\n return targets.map((target) => {\n const baseConfig = factory(target, bundlerContext);\n const configMutator = new WebpackConfigMutator(baseConfig);\n const context = Object.assign({}, transformerContext, { target });\n const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, context);\n return afterMutation.raw;\n });\n }\n\n private createDevServerConfig(\n entry: string[],\n rootPath: string,\n devServerID: string,\n publicRoot: string,\n publicPath: string,\n title?: string\n ) {\n return devServerConfigFactory(devServerID, rootPath, entry, publicRoot, publicPath, this.pubsub, title);\n }\n\n static slots = [];\n\n static runtime = MainRuntime;\n static dependencies = [PubsubAspect, WorkspaceAspect, BundlerAspect, LoggerAspect];\n\n static async provider([pubsub, workspace, bundler, logger]: [PubsubMain, Workspace, BundlerMain, LoggerMain]) {\n const logPublisher = logger.createLogger(WebpackAspect.id);\n return new WebpackMain(pubsub, workspace, bundler, logPublisher);\n }\n}\n\nWebpackAspect.addRuntime(WebpackMain);\n\nexport function runTransformersWithContext(\n config: WebpackConfigMutator,\n transformers: Array<WebpackConfigTransformer | WebpackConfigDevServerTransformer> = [],\n context: WebpackConfigTransformContext | WebpackConfigDevServerTransformContext\n): WebpackConfigMutator {\n if (!Array.isArray(transformers)) return config;\n const newConfig = transformers.reduce((acc, transformer) => {\n // @ts-ignore\n return transformer(acc, context);\n }, config);\n return newConfig;\n}\n"]}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/webpack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.629",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/webpack/webpack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.webpack",
|
|
8
8
|
"name": "webpack",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.629"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"webpack": "5.51.1",
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
"p-map-series": "2.1.0",
|
|
15
15
|
"webpack-dev-server": "4.1.0",
|
|
16
16
|
"webpack-merge": "5.8.0",
|
|
17
|
+
"camelcase": "6.2.0",
|
|
17
18
|
"html-webpack-plugin": "5.3.2",
|
|
19
|
+
"lodash": "4.17.21",
|
|
20
|
+
"webpack-assets-manifest": "5.1.0",
|
|
18
21
|
"react-dev-utils": "11.0.4",
|
|
19
22
|
"vm-browserify": "1.1.2",
|
|
20
23
|
"util": "0.12.3",
|
|
@@ -38,25 +41,27 @@
|
|
|
38
41
|
"assert": "2.0.0",
|
|
39
42
|
"@babel/runtime": "7.12.18",
|
|
40
43
|
"core-js": "^3.0.0",
|
|
41
|
-
"@teambit/webpack.modules.config-mutator": "0.0.
|
|
44
|
+
"@teambit/webpack.modules.config-mutator": "0.0.136",
|
|
42
45
|
"@teambit/bit-error": "0.0.394",
|
|
43
|
-
"@teambit/bundler": "0.0.
|
|
44
|
-
"@teambit/logger": "0.0.
|
|
45
|
-
"@teambit/cli": "0.0.
|
|
46
|
-
"@teambit/pubsub": "0.0.
|
|
47
|
-
"@teambit/workspace": "0.0.
|
|
46
|
+
"@teambit/bundler": "0.0.629",
|
|
47
|
+
"@teambit/logger": "0.0.522",
|
|
48
|
+
"@teambit/cli": "0.0.433",
|
|
49
|
+
"@teambit/pubsub": "0.0.629",
|
|
50
|
+
"@teambit/workspace": "0.0.629",
|
|
51
|
+
"@teambit/webpack.modules.generate-externals": "0.0.2"
|
|
48
52
|
},
|
|
49
53
|
"devDependencies": {
|
|
50
54
|
"@types/webpack": "5.28.0",
|
|
51
55
|
"@types/react": "^17.0.8",
|
|
52
56
|
"@types/webpack-dev-server": "4.0.3",
|
|
57
|
+
"@types/lodash": "4.14.165",
|
|
53
58
|
"@types/testing-library__jest-dom": "5.9.5",
|
|
54
59
|
"@types/jest": "^26.0.0",
|
|
55
60
|
"@types/react-dom": "^17.0.5",
|
|
56
61
|
"@types/node": "12.20.4"
|
|
57
62
|
},
|
|
58
63
|
"peerDependencies": {
|
|
59
|
-
"@teambit/legacy": "1.0.
|
|
64
|
+
"@teambit/legacy": "1.0.209",
|
|
60
65
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
61
66
|
"react": "^16.8.0 || ^17.0.0"
|
|
62
67
|
},
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import webpack, { Configuration } from 'webpack';
|
|
2
|
-
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
3
|
-
import { fallbacks } from './webpack-fallbacks';
|
|
4
|
-
import { fallbacksProvidePluginConfig } from './webpack-fallbacks-provide-plugin-config';
|
|
5
|
-
import { fallbacksAliases } from './webpack-fallbacks-aliases';
|
|
6
|
-
import { html } from './html';
|
|
7
|
-
|
|
8
|
-
export function previewConfigFactory(entries: string[], rootPath: string): Configuration {
|
|
9
|
-
return {
|
|
10
|
-
mode: 'production',
|
|
11
|
-
// Stop compilation early in production
|
|
12
|
-
bail: true,
|
|
13
|
-
// These are the "entry points" to our application.
|
|
14
|
-
// This means they will be the "root" imports that are included in JS bundle.
|
|
15
|
-
entry: entries.filter(Boolean),
|
|
16
|
-
|
|
17
|
-
output: {
|
|
18
|
-
// The build folder.
|
|
19
|
-
path: `${rootPath}/public`,
|
|
20
|
-
|
|
21
|
-
filename: 'static/js/[name].[contenthash:8].js',
|
|
22
|
-
// There are also additional JS chunk files if you use code splitting.
|
|
23
|
-
chunkFilename: 'static/js/[name].[contenthash:8].chunk.js',
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
resolve: {
|
|
27
|
-
alias: fallbacksAliases,
|
|
28
|
-
|
|
29
|
-
fallback: fallbacks,
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
plugins: [
|
|
33
|
-
new HtmlWebpackPlugin(
|
|
34
|
-
Object.assign(
|
|
35
|
-
{},
|
|
36
|
-
{
|
|
37
|
-
inject: true,
|
|
38
|
-
templateContent: html('Preview'),
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
minify: {
|
|
42
|
-
removeComments: true,
|
|
43
|
-
collapseWhitespace: true,
|
|
44
|
-
removeRedundantAttributes: true,
|
|
45
|
-
useShortDoctype: true,
|
|
46
|
-
removeEmptyAttributes: true,
|
|
47
|
-
removeStyleLinkTypeAttributes: true,
|
|
48
|
-
keepClosingSlash: true,
|
|
49
|
-
minifyJS: true,
|
|
50
|
-
minifyCSS: true,
|
|
51
|
-
minifyURLs: true,
|
|
52
|
-
},
|
|
53
|
-
}
|
|
54
|
-
)
|
|
55
|
-
),
|
|
56
|
-
new webpack.ProvidePlugin(fallbacksProvidePluginConfig),
|
|
57
|
-
],
|
|
58
|
-
};
|
|
59
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.previewConfigFactory = previewConfigFactory;
|
|
9
|
-
|
|
10
|
-
function _webpack() {
|
|
11
|
-
const data = _interopRequireDefault(require("webpack"));
|
|
12
|
-
|
|
13
|
-
_webpack = function () {
|
|
14
|
-
return data;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
return data;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _htmlWebpackPlugin() {
|
|
21
|
-
const data = _interopRequireDefault(require("html-webpack-plugin"));
|
|
22
|
-
|
|
23
|
-
_htmlWebpackPlugin = function () {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
return data;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function _webpackFallbacks() {
|
|
31
|
-
const data = require("./webpack-fallbacks");
|
|
32
|
-
|
|
33
|
-
_webpackFallbacks = function () {
|
|
34
|
-
return data;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return data;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _webpackFallbacksProvidePluginConfig() {
|
|
41
|
-
const data = require("./webpack-fallbacks-provide-plugin-config");
|
|
42
|
-
|
|
43
|
-
_webpackFallbacksProvidePluginConfig = function () {
|
|
44
|
-
return data;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _webpackFallbacksAliases() {
|
|
51
|
-
const data = require("./webpack-fallbacks-aliases");
|
|
52
|
-
|
|
53
|
-
_webpackFallbacksAliases = function () {
|
|
54
|
-
return data;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return data;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function _html() {
|
|
61
|
-
const data = require("./html");
|
|
62
|
-
|
|
63
|
-
_html = function () {
|
|
64
|
-
return data;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
return data;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function previewConfigFactory(entries, rootPath) {
|
|
71
|
-
return {
|
|
72
|
-
mode: 'production',
|
|
73
|
-
// Stop compilation early in production
|
|
74
|
-
bail: true,
|
|
75
|
-
// These are the "entry points" to our application.
|
|
76
|
-
// This means they will be the "root" imports that are included in JS bundle.
|
|
77
|
-
entry: entries.filter(Boolean),
|
|
78
|
-
output: {
|
|
79
|
-
// The build folder.
|
|
80
|
-
path: `${rootPath}/public`,
|
|
81
|
-
filename: 'static/js/[name].[contenthash:8].js',
|
|
82
|
-
// There are also additional JS chunk files if you use code splitting.
|
|
83
|
-
chunkFilename: 'static/js/[name].[contenthash:8].chunk.js'
|
|
84
|
-
},
|
|
85
|
-
resolve: {
|
|
86
|
-
alias: _webpackFallbacksAliases().fallbacksAliases,
|
|
87
|
-
fallback: _webpackFallbacks().fallbacks
|
|
88
|
-
},
|
|
89
|
-
plugins: [new (_htmlWebpackPlugin().default)(Object.assign({}, {
|
|
90
|
-
inject: true,
|
|
91
|
-
templateContent: (0, _html().html)('Preview')
|
|
92
|
-
}, {
|
|
93
|
-
minify: {
|
|
94
|
-
removeComments: true,
|
|
95
|
-
collapseWhitespace: true,
|
|
96
|
-
removeRedundantAttributes: true,
|
|
97
|
-
useShortDoctype: true,
|
|
98
|
-
removeEmptyAttributes: true,
|
|
99
|
-
removeStyleLinkTypeAttributes: true,
|
|
100
|
-
keepClosingSlash: true,
|
|
101
|
-
minifyJS: true,
|
|
102
|
-
minifyCSS: true,
|
|
103
|
-
minifyURLs: true
|
|
104
|
-
}
|
|
105
|
-
})), new (_webpack().default.ProvidePlugin)(_webpackFallbacksProvidePluginConfig().fallbacksProvidePluginConfig)]
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
//# sourceMappingURL=webpack-preview.config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack-preview.config.ts"],"names":["previewConfigFactory","entries","rootPath","mode","bail","entry","filter","Boolean","output","path","filename","chunkFilename","resolve","alias","fallbacksAliases","fallback","fallbacks","plugins","HtmlWebpackPlugin","Object","assign","inject","templateContent","minify","removeComments","collapseWhitespace","removeRedundantAttributes","useShortDoctype","removeEmptyAttributes","removeStyleLinkTypeAttributes","keepClosingSlash","minifyJS","minifyCSS","minifyURLs","webpack","ProvidePlugin","fallbacksProvidePluginConfig"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AA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-plugin';\nimport { fallbacks } from './webpack-fallbacks';\nimport { fallbacksProvidePluginConfig } from './webpack-fallbacks-provide-plugin-config';\nimport { fallbacksAliases } from './webpack-fallbacks-aliases';\nimport { html } from './html';\n\nexport function previewConfigFactory(entries: string[], rootPath: string): Configuration {\n return {\n mode: 'production',\n // Stop compilation early in production\n bail: true,\n // These are the \"entry points\" to our application.\n // This means they will be the \"root\" imports that are included in JS bundle.\n entry: entries.filter(Boolean),\n\n output: {\n // The build folder.\n path: `${rootPath}/public`,\n\n filename: 'static/js/[name].[contenthash:8].js',\n // There are also additional JS chunk files if you use code splitting.\n chunkFilename: 'static/js/[name].[contenthash:8].chunk.js',\n },\n\n resolve: {\n alias: fallbacksAliases,\n\n fallback: fallbacks,\n },\n\n plugins: [\n new HtmlWebpackPlugin(\n Object.assign(\n {},\n {\n inject: true,\n templateContent: html('Preview'),\n },\n {\n minify: {\n removeComments: true,\n collapseWhitespace: true,\n removeRedundantAttributes: true,\n useShortDoctype: true,\n removeEmptyAttributes: true,\n removeStyleLinkTypeAttributes: true,\n keepClosingSlash: true,\n minifyJS: true,\n minifyCSS: true,\n minifyURLs: true,\n },\n }\n )\n ),\n new webpack.ProvidePlugin(fallbacksProvidePluginConfig),\n ],\n };\n}\n"]}
|
|
Binary file
|