@teambit/webpack 0.0.567 → 0.0.571
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/config/html.ts +22 -0
- package/config/webpack-fallbacks-aliases.ts +4 -0
- package/config/webpack-fallbacks-provide-plugin-config.ts +4 -0
- package/config/webpack-fallbacks.ts +60 -0
- package/config/webpack-preview.config.ts +59 -0
- package/config/webpack.config.ts +32 -0
- package/config/webpack.dev.config.ts +156 -0
- package/events/index.ts +2 -0
- package/events/webpack-compilation-done-event.ts +20 -0
- package/events/webpack-compilation-started-event.ts +14 -0
- package/package-tar/teambit-webpack-0.0.571.tgz +0 -0
- package/package.json +10 -25
- package/plugins/webpack-bit-reporter-plugin.ts +33 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
- package/webpack.composition.tsx +7 -0
package/config/html.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** html template for Previews (docs, compositions, etc) */
|
|
2
|
+
export function html(title: string) {
|
|
3
|
+
return () => `
|
|
4
|
+
<!DOCTYPE html>
|
|
5
|
+
<html lang="en">
|
|
6
|
+
<head>
|
|
7
|
+
<meta charset="utf-8">
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
9
|
+
<title>${title}</title>
|
|
10
|
+
<script>
|
|
11
|
+
// Allow to use react dev-tools inside the examples
|
|
12
|
+
try { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__; } catch {}
|
|
13
|
+
</script>
|
|
14
|
+
<!-- minimal css resets -->
|
|
15
|
+
<style> html { height: 100%; } body { margin: 0; height: 100%; } #root { height: 100%; } </style>
|
|
16
|
+
</head>
|
|
17
|
+
<body>
|
|
18
|
+
<div id="root"></div>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
|
21
|
+
`;
|
|
22
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// based on https://github1s.com/vercel/next.js/blob/canary/packages/next/build/webpack-config.ts
|
|
2
|
+
// Full list of old polyfills is accessible here:
|
|
3
|
+
// https://github.com/webpack/webpack/blob/2a0536cf510768111a3a6dceeb14cb79b9f59273/lib/ModuleNotFoundError.js#L13-L42
|
|
4
|
+
|
|
5
|
+
const assertFallbackPath = require.resolve('assert/');
|
|
6
|
+
const bufferFallbackPath = require.resolve('buffer/');
|
|
7
|
+
const constantsFallbackPath = require.resolve('constants-browserify');
|
|
8
|
+
const cryptoFallbackPath = require.resolve('crypto-browserify');
|
|
9
|
+
const domainFallbackPath = require.resolve('domain-browser');
|
|
10
|
+
const httpFallbackPath = require.resolve('stream-http');
|
|
11
|
+
const httpsFallbackPath = require.resolve('https-browserify');
|
|
12
|
+
const osFallbackPath = require.resolve('os-browserify/browser');
|
|
13
|
+
const pathFallbackPath = require.resolve('path-browserify');
|
|
14
|
+
const punycodeFallbackPath = require.resolve('punycode/');
|
|
15
|
+
const processFallbackPath = require.resolve('process/browser');
|
|
16
|
+
// Handled in separate alias
|
|
17
|
+
const querystringFallbackPath = require.resolve('querystring-es3');
|
|
18
|
+
const streamFallbackPath = require.resolve('stream-browserify');
|
|
19
|
+
const string_decoderFallbackPath = require.resolve('string_decoder/');
|
|
20
|
+
const sysFallbackPath = require.resolve('util/');
|
|
21
|
+
const timersFallbackPath = require.resolve('timers-browserify');
|
|
22
|
+
const ttyFallbackPath = require.resolve('tty-browserify');
|
|
23
|
+
// Handled in separate alias
|
|
24
|
+
const urlFallbackPath = require.resolve('url/');
|
|
25
|
+
const utilFallbackPath = require.resolve('util/');
|
|
26
|
+
const vmFallbackPath = require.resolve('vm-browserify');
|
|
27
|
+
const zlibFallbackPath = require.resolve('browserify-zlib');
|
|
28
|
+
|
|
29
|
+
export const fallbacks = {
|
|
30
|
+
assert: assertFallbackPath,
|
|
31
|
+
buffer: bufferFallbackPath,
|
|
32
|
+
constants: constantsFallbackPath,
|
|
33
|
+
crypto: cryptoFallbackPath,
|
|
34
|
+
domain: domainFallbackPath,
|
|
35
|
+
http: httpFallbackPath,
|
|
36
|
+
https: httpsFallbackPath,
|
|
37
|
+
os: osFallbackPath,
|
|
38
|
+
path: pathFallbackPath,
|
|
39
|
+
punycode: punycodeFallbackPath,
|
|
40
|
+
process: processFallbackPath,
|
|
41
|
+
querystring: querystringFallbackPath,
|
|
42
|
+
stream: streamFallbackPath,
|
|
43
|
+
string_decoder: string_decoderFallbackPath,
|
|
44
|
+
sys: sysFallbackPath,
|
|
45
|
+
timers: timersFallbackPath,
|
|
46
|
+
tty: ttyFallbackPath,
|
|
47
|
+
url: urlFallbackPath,
|
|
48
|
+
util: utilFallbackPath,
|
|
49
|
+
vm: vmFallbackPath,
|
|
50
|
+
zlib: zlibFallbackPath,
|
|
51
|
+
fs: false,
|
|
52
|
+
net: false,
|
|
53
|
+
tls: false,
|
|
54
|
+
child_process: false,
|
|
55
|
+
// file: false,
|
|
56
|
+
// module: false,
|
|
57
|
+
// pnpapi: false,
|
|
58
|
+
// readline: false,
|
|
59
|
+
// worker_threads: false,
|
|
60
|
+
} as const;
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import webpack, { Configuration } from 'webpack';
|
|
2
|
+
import { fallbacks } from './webpack-fallbacks';
|
|
3
|
+
import { fallbacksProvidePluginConfig } from './webpack-fallbacks-provide-plugin-config';
|
|
4
|
+
import { fallbacksAliases } from './webpack-fallbacks-aliases';
|
|
5
|
+
|
|
6
|
+
export function configFactory(entries: string[], rootPath: string): Configuration {
|
|
7
|
+
return {
|
|
8
|
+
mode: 'production',
|
|
9
|
+
// Stop compilation early in production
|
|
10
|
+
bail: true,
|
|
11
|
+
// These are the "entry points" to our application.
|
|
12
|
+
// This means they will be the "root" imports that are included in JS bundle.
|
|
13
|
+
entry: entries.filter(Boolean),
|
|
14
|
+
|
|
15
|
+
output: {
|
|
16
|
+
// The build folder.
|
|
17
|
+
path: `${rootPath}/public`,
|
|
18
|
+
|
|
19
|
+
filename: 'static/js/[name].[contenthash:8].js',
|
|
20
|
+
// There are also additional JS chunk files if you use code splitting.
|
|
21
|
+
chunkFilename: 'static/js/[name].[contenthash:8].chunk.js',
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
resolve: {
|
|
25
|
+
alias: fallbacksAliases,
|
|
26
|
+
|
|
27
|
+
fallback: fallbacks,
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
plugins: [new webpack.ProvidePlugin(fallbacksProvidePluginConfig)],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import webpack from 'webpack';
|
|
3
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
4
|
+
import errorOverlayMiddleware from 'react-dev-utils/errorOverlayMiddleware';
|
|
5
|
+
import evalSourceMapMiddleware from 'react-dev-utils/evalSourceMapMiddleware';
|
|
6
|
+
import noopServiceWorkerMiddleware from 'react-dev-utils/noopServiceWorkerMiddleware';
|
|
7
|
+
import redirectServedPath from 'react-dev-utils/redirectServedPathMiddleware';
|
|
8
|
+
import getPublicUrlOrPath from 'react-dev-utils/getPublicUrlOrPath';
|
|
9
|
+
import { PubsubMain } from '@teambit/pubsub';
|
|
10
|
+
import { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';
|
|
11
|
+
import { WebpackConfigWithDevServer } from '../webpack.dev-server';
|
|
12
|
+
import { fallbacks } from './webpack-fallbacks';
|
|
13
|
+
|
|
14
|
+
import { html } from './html';
|
|
15
|
+
|
|
16
|
+
import { WebpackBitReporterPlugin } from '../plugins/webpack-bit-reporter-plugin';
|
|
17
|
+
import { fallbacksProvidePluginConfig } from './webpack-fallbacks-provide-plugin-config';
|
|
18
|
+
import { fallbacksAliases } from './webpack-fallbacks-aliases';
|
|
19
|
+
|
|
20
|
+
const publicUrlOrPath = getPublicUrlOrPath(process.env.NODE_ENV === 'development', '/', '/public');
|
|
21
|
+
|
|
22
|
+
export function configFactory(
|
|
23
|
+
devServerID: string,
|
|
24
|
+
workspaceDir: string,
|
|
25
|
+
entryFiles: string[],
|
|
26
|
+
publicRoot: string,
|
|
27
|
+
publicPath: string,
|
|
28
|
+
pubsub: PubsubMain,
|
|
29
|
+
title?: string
|
|
30
|
+
): WebpackConfigWithDevServer {
|
|
31
|
+
const resolveWorkspacePath = (relativePath) => path.resolve(workspaceDir, relativePath);
|
|
32
|
+
|
|
33
|
+
// Required for babel-preset-react-app
|
|
34
|
+
process.env.NODE_ENV = 'development';
|
|
35
|
+
|
|
36
|
+
const publicDirectory = `${publicRoot}/${publicPath}`;
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
// Environment mode
|
|
40
|
+
mode: 'development',
|
|
41
|
+
|
|
42
|
+
devtool: 'inline-source-map',
|
|
43
|
+
|
|
44
|
+
// Entry point of app
|
|
45
|
+
entry: entryFiles.map((filePath) => resolveWorkspacePath(filePath)),
|
|
46
|
+
|
|
47
|
+
output: {
|
|
48
|
+
// Development filename output
|
|
49
|
+
filename: 'static/js/[name].bundle.js',
|
|
50
|
+
|
|
51
|
+
pathinfo: true,
|
|
52
|
+
|
|
53
|
+
path: resolveWorkspacePath(publicDirectory),
|
|
54
|
+
|
|
55
|
+
// publicPath: resolveWorkspacePath(publicDirectory),
|
|
56
|
+
|
|
57
|
+
chunkFilename: 'static/js/[name].chunk.js',
|
|
58
|
+
|
|
59
|
+
// point sourcemap entries to original disk locations (format as URL on windows)
|
|
60
|
+
devtoolModuleFilenameTemplate: (info) => pathNormalizeToLinux(path.resolve(info.absoluteResourcePath)),
|
|
61
|
+
|
|
62
|
+
// this defaults to 'window', but by setting it to 'this' then
|
|
63
|
+
// module chunks which are built will work in web workers as well.
|
|
64
|
+
// Commented out to use the default (self) as according to tobias with webpack5 self is working with workers as well
|
|
65
|
+
// globalObject: 'this',
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
infrastructureLogging: {
|
|
69
|
+
level: 'error',
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
stats: 'errors-only',
|
|
73
|
+
|
|
74
|
+
devServer: {
|
|
75
|
+
allowedHosts: 'all',
|
|
76
|
+
|
|
77
|
+
static: [
|
|
78
|
+
{
|
|
79
|
+
directory: resolveWorkspacePath(publicDirectory),
|
|
80
|
+
staticOptions: {},
|
|
81
|
+
// Don't be confused with `dev.publicPath`, it is `publicPath` for static directory
|
|
82
|
+
// Can be:
|
|
83
|
+
// publicPath: ['/static-public-path-one/', '/static-public-path-two/'],
|
|
84
|
+
publicPath: publicDirectory,
|
|
85
|
+
// Can be:
|
|
86
|
+
// serveIndex: {} (options for the `serveIndex` option you can find https://github.com/expressjs/serve-index)
|
|
87
|
+
serveIndex: true,
|
|
88
|
+
// Can be:
|
|
89
|
+
// watch: {} (options for the `watch` option you can find https://github.com/paulmillr/chokidar)
|
|
90
|
+
watch: true,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
|
|
94
|
+
// Enable compression
|
|
95
|
+
compress: true,
|
|
96
|
+
|
|
97
|
+
// Enable hot reloading
|
|
98
|
+
hot: true,
|
|
99
|
+
|
|
100
|
+
historyApiFallback: {
|
|
101
|
+
disableDotRule: true,
|
|
102
|
+
index: resolveWorkspacePath(publicDirectory),
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
client: {
|
|
106
|
+
overlay: false,
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
onBeforeSetupMiddleware({ app, server }) {
|
|
110
|
+
// Keep `evalSourceMapMiddleware` and `errorOverlayMiddleware`
|
|
111
|
+
// middlewares before `redirectServedPath` otherwise will not have any effect
|
|
112
|
+
// This lets us fetch source contents from webpack for the error overlay
|
|
113
|
+
app.use(evalSourceMapMiddleware(server));
|
|
114
|
+
// This lets us open files from the runtime error overlay.
|
|
115
|
+
app.use(errorOverlayMiddleware());
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
onAfterSetupMiddleware({ app }) {
|
|
119
|
+
// Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
|
|
120
|
+
app.use(redirectServedPath(publicUrlOrPath));
|
|
121
|
+
|
|
122
|
+
// This service worker file is effectively a 'no-op' that will reset any
|
|
123
|
+
// previous service worker registered for the same host:port combination.
|
|
124
|
+
// We do this in development to avoid hitting the production cache if
|
|
125
|
+
// it used the same host and port.
|
|
126
|
+
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
|
|
127
|
+
app.use(noopServiceWorkerMiddleware(publicUrlOrPath));
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
devMiddleware: {
|
|
131
|
+
// forward static files
|
|
132
|
+
publicPath: path.join('/', publicRoot),
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
resolve: {
|
|
137
|
+
extensions: ['.ts', '.tsx', '.js', '.mdx', '.md'],
|
|
138
|
+
alias: fallbacksAliases,
|
|
139
|
+
|
|
140
|
+
fallback: fallbacks as any,
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
plugins: [
|
|
144
|
+
new HtmlWebpackPlugin({
|
|
145
|
+
templateContent: html(title || 'Component preview'),
|
|
146
|
+
filename: 'index.html',
|
|
147
|
+
}),
|
|
148
|
+
|
|
149
|
+
new webpack.ProvidePlugin(fallbacksProvidePluginConfig),
|
|
150
|
+
|
|
151
|
+
new WebpackBitReporterPlugin({
|
|
152
|
+
options: { pubsub, devServerID },
|
|
153
|
+
}),
|
|
154
|
+
],
|
|
155
|
+
};
|
|
156
|
+
}
|
package/events/index.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import type { Stats } from 'webpack';
|
|
3
|
+
import { BitBaseEvent } from '@teambit/pubsub';
|
|
4
|
+
|
|
5
|
+
class WebpackCompilationDoneEventData {
|
|
6
|
+
constructor(readonly stats: Stats, readonly devServerID: string) {}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class WebpackCompilationDoneEvent extends BitBaseEvent<WebpackCompilationDoneEventData> {
|
|
10
|
+
static readonly TYPE = 'webpack-compilation-done';
|
|
11
|
+
|
|
12
|
+
constructor(readonly timestamp: number, readonly stats: Stats, readonly devServerID: string) {
|
|
13
|
+
super(
|
|
14
|
+
WebpackCompilationDoneEvent.TYPE,
|
|
15
|
+
'0.0.1',
|
|
16
|
+
timestamp,
|
|
17
|
+
new WebpackCompilationDoneEventData(stats, devServerID)
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import { BitBaseEvent } from '@teambit/pubsub';
|
|
3
|
+
|
|
4
|
+
type Params = {
|
|
5
|
+
devServerID: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export class WebpackCompilationStartedEvent extends BitBaseEvent<Params> {
|
|
9
|
+
static readonly TYPE = 'webpack-compilation-started';
|
|
10
|
+
|
|
11
|
+
constructor(readonly timestamp, readonly params: Params) {
|
|
12
|
+
super(WebpackCompilationStartedEvent.TYPE, '0.0.1', timestamp, params);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
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.571",
|
|
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.571"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"webpack": "5.51.1",
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"assert": "2.0.0",
|
|
39
39
|
"@babel/runtime": "7.12.18",
|
|
40
40
|
"core-js": "^3.0.0",
|
|
41
|
-
"@teambit/webpack.modules.config-mutator": "0.0.
|
|
42
|
-
"@teambit/bit-error": "0.0.
|
|
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.
|
|
41
|
+
"@teambit/webpack.modules.config-mutator": "0.0.121",
|
|
42
|
+
"@teambit/bit-error": "0.0.381",
|
|
43
|
+
"@teambit/bundler": "0.0.571",
|
|
44
|
+
"@teambit/logger": "0.0.483",
|
|
45
|
+
"@teambit/cli": "0.0.395",
|
|
46
|
+
"@teambit/pubsub": "0.0.571",
|
|
47
|
+
"@teambit/workspace": "0.0.571"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/webpack": "5.28.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@types/node": "12.20.4"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@teambit/legacy": "1.0.
|
|
59
|
+
"@teambit/legacy": "1.0.181",
|
|
60
60
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
@@ -107,21 +107,6 @@
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
|
-
"files": [
|
|
111
|
-
"dist",
|
|
112
|
-
"!dist/tsconfig.tsbuildinfo",
|
|
113
|
-
"**/*.md",
|
|
114
|
-
"**/*.mdx",
|
|
115
|
-
"**/*.js",
|
|
116
|
-
"**/*.json",
|
|
117
|
-
"**/*.sass",
|
|
118
|
-
"**/*.scss",
|
|
119
|
-
"**/*.less",
|
|
120
|
-
"**/*.css",
|
|
121
|
-
"**/*.css",
|
|
122
|
-
"**/*.jpeg",
|
|
123
|
-
"**/*.gif"
|
|
124
|
-
],
|
|
125
110
|
"private": false,
|
|
126
111
|
"engines": {
|
|
127
112
|
"node": ">=12.22.0"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Compiler, Stats } from 'webpack';
|
|
2
|
+
import { WebpackCompilationDoneEvent, WebpackCompilationStartedEvent } from '../events';
|
|
3
|
+
import { WebpackAspect } from '../webpack.aspect';
|
|
4
|
+
|
|
5
|
+
const PLUGIN_NAME = 'webpack-compiler-started-plugin';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Monitors Webpack's compilation, and updates progress to Bit
|
|
9
|
+
*/
|
|
10
|
+
export class WebpackBitReporterPlugin {
|
|
11
|
+
// TODO: add plugin type from webpack and implement it
|
|
12
|
+
pubsub: any;
|
|
13
|
+
devServerID: string;
|
|
14
|
+
|
|
15
|
+
constructor({ options }) {
|
|
16
|
+
this.pubsub = options.pubsub;
|
|
17
|
+
this.devServerID = options.devServerID;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
apply(compiler: Compiler) {
|
|
21
|
+
// "Called before a new compilation is created."
|
|
22
|
+
compiler.hooks.compile.tap(PLUGIN_NAME, () => {
|
|
23
|
+
const event = new WebpackCompilationStartedEvent(Date.now(), { devServerID: this.devServerID });
|
|
24
|
+
this.pubsub.pub(WebpackAspect.id, event);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// "Executed when the compilation has completed."
|
|
28
|
+
compiler.hooks.done.tap(PLUGIN_NAME, (stats: Stats) => {
|
|
29
|
+
const event = new WebpackCompilationDoneEvent(Date.now(), stats, this.devServerID);
|
|
30
|
+
this.pubsub.pub(WebpackAspect.id, event);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
+
const src: string;
|
|
10
|
+
export default src;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// @TODO Gilad
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|