mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix: double build (#2045)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
"sideEffects": [
|
||||
"src/**/*.css",
|
||||
"src/**/*.scss",
|
||||
"public/**",
|
||||
"public/**/*"
|
||||
],
|
||||
"version": "0.1.0",
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
const { resolve } = require('path');
|
||||
const PnpWebpackPlugin = require('pnp-webpack-plugin');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const { CSSSourceResolver } = require('../utils/CSSSourceResolver.js');
|
||||
const { SourceAssetsResolver } = require('../utils/SourceAssetsResolver.js');
|
||||
const { IgnoreNotFoundExportPlugin } = require('../utils/IgnoreNotFoundExportPlugin.js');
|
||||
const excludedFromVendor = require('./excludedFromVendor.js');
|
||||
|
||||
const supportedStyles = /\.(css|s[ac]ss)$/;
|
||||
const webpack = require('webpack');
|
||||
|
||||
const nodeModules = [
|
||||
resolve('node_modules'), // product
|
||||
@@ -154,7 +153,7 @@ module.exports = (env, argv) => {
|
||||
resolve: {
|
||||
extensions: ['.ts', '.tsx', '.wasm', '.mjs', '.js', '.jsx', '.json'],
|
||||
modules: nodeModules,
|
||||
plugins: [PnpWebpackPlugin, new CSSSourceResolver(supportedStyles)],
|
||||
plugins: [PnpWebpackPlugin, new SourceAssetsResolver(['.json5', '.css', '.scss'])],
|
||||
},
|
||||
resolveLoader: {
|
||||
modules: nodeModules,
|
||||
@@ -162,33 +161,18 @@ module.exports = (env, argv) => {
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
devMode && {
|
||||
test: /\.jsx?$/,
|
||||
enforce: 'pre',
|
||||
exclude: /node_modules/,
|
||||
use: ['source-map-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.json5$/i,
|
||||
loader: 'json5-loader',
|
||||
type: 'javascript/auto',
|
||||
},
|
||||
{
|
||||
test: /\.jsx?$/,
|
||||
exclude: /node_modules/,
|
||||
use: ['thread-loader', babelLoader],
|
||||
},
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
// 'thread-loader',
|
||||
babelLoader,
|
||||
{
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
// happyPackMode: true,
|
||||
// transpileOnly: true,
|
||||
compilerOptions: {
|
||||
sourceMap: devMode,
|
||||
},
|
||||
projectReferences: true,
|
||||
ignoreDiagnostics: [6059, 2307],
|
||||
},
|
||||
@@ -196,7 +180,23 @@ module.exports = (env, argv) => {
|
||||
],
|
||||
},
|
||||
{
|
||||
test: supportedStyles,
|
||||
test: /\.json5$/i,
|
||||
loader: 'json5-loader',
|
||||
type: 'javascript/auto',
|
||||
},
|
||||
devMode && {
|
||||
test: /\.jsx?$/,
|
||||
enforce: 'pre',
|
||||
exclude: /node_modules/,
|
||||
use: ['source-map-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.jsx?$/,
|
||||
exclude: /node_modules/,
|
||||
use: ['thread-loader', babelLoader],
|
||||
},
|
||||
{
|
||||
test: /\.(css|s[ac]ss)$/,
|
||||
exclude: /node_modules/,
|
||||
oneOf: [
|
||||
{
|
||||
@@ -260,6 +260,9 @@ module.exports = (env, argv) => {
|
||||
// },
|
||||
// },
|
||||
// }),
|
||||
// new webpack.WatchIgnorePlugin({
|
||||
// paths: [/\.jsx?$/, /\.d\.[cm]ts$/],
|
||||
// }),
|
||||
new IgnoreNotFoundExportPlugin(),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: devMode ? 'styles/[name].css' : 'styles/[name].[contenthash].css',
|
||||
|
||||
@@ -10,8 +10,8 @@ const commonConfig = require('./webpack.config.js');
|
||||
const { getAssets, withTimestamp } = require('./webpack.product.utils');
|
||||
const HtmlInjectWebpackPlugin = require('../utils/HtmlInjectWebpackPlugin.js');
|
||||
|
||||
const main = resolve('src/index.ts');
|
||||
const sso = require.resolve('@cloudbeaver/plugin-sso/src/index.ts');
|
||||
const main = resolve('dist/index.js');
|
||||
const sso = require.resolve('@cloudbeaver/plugin-sso/dist/index.js');
|
||||
const ssoHtmlTemplate = require.resolve('@cloudbeaver/plugin-sso/src/index.html.ejs');
|
||||
const outputDir = resolve('lib');
|
||||
const package = require(resolve('package.json'));
|
||||
|
||||
@@ -6,8 +6,8 @@ const fs = require('fs');
|
||||
const { URL } = require('url');
|
||||
|
||||
const commonConfig = require('./webpack.config.js');
|
||||
const index = resolve('src/index.ts');
|
||||
const sso = require.resolve('@cloudbeaver/plugin-sso/src/index.ts');
|
||||
const index = resolve('dist/index.js');
|
||||
const sso = require.resolve('@cloudbeaver/plugin-sso/dist/index.js');
|
||||
const ssoHtmlTemplate = require.resolve('@cloudbeaver/plugin-sso/src/index.html.ejs');
|
||||
const { getAssets } = require('./webpack.product.utils');
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ const { resolve } = require('path');
|
||||
const { getCloudBeaverDeps } = require('../utils/getCloudBeaverDeps');
|
||||
|
||||
function getServiceWorkerSource() {
|
||||
return require.resolve('@cloudbeaver/core-browser/src/service-worker.ts');
|
||||
return require.resolve('@cloudbeaver/core-browser/dist/service-worker.js');
|
||||
}
|
||||
|
||||
function withTimestamp(version) {
|
||||
|
||||
+6
-6
@@ -6,22 +6,22 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
class CSSSourceResolver {
|
||||
class SourceAssetsResolver {
|
||||
// https://github.com/webpack/enhanced-resolve/
|
||||
constructor(supportedStyles) {
|
||||
constructor(extensions) {
|
||||
this.source = 'after-normal-resolve';
|
||||
this.target = 'relative';
|
||||
this.supportedStyles = supportedStyles;
|
||||
this.extensions = extensions;
|
||||
}
|
||||
|
||||
apply(resolver) {
|
||||
const target = resolver.ensureHook(this.target);
|
||||
resolver.getHook(this.source).tapAsync('CSSSourceResolver', (request, resolveContext, callback) => {
|
||||
resolver.getHook(this.source).tapAsync('SourceAssetsResolver', (request, resolveContext, callback) => {
|
||||
const descriptionFileRoot = /** @type {string} */ (request.descriptionFileRoot);
|
||||
let relativePath = /** @type {string} */ (request.relativePath);
|
||||
const requestRequest = /** @type {string | undefined} */ (request.request);
|
||||
|
||||
if (this.supportedStyles.test(requestRequest) && relativePath.startsWith('./dist')) {
|
||||
if (relativePath?.startsWith('./dist') && this.extensions.some(ext => requestRequest?.endsWith(ext))) {
|
||||
relativePath = './' + resolver.join(relativePath.replace('./dist', './src'), requestRequest);
|
||||
const path = resolver.join(descriptionFileRoot, relativePath);
|
||||
const obj = {
|
||||
@@ -40,7 +40,7 @@ class CSSSourceResolver {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
CSSSourceResolver,
|
||||
SourceAssetsResolver,
|
||||
};
|
||||
|
||||
// class CSSSourceResolver {
|
||||
@@ -3,7 +3,7 @@
|
||||
"baseUrl": ".",
|
||||
"allowUnreachableCode": false,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"allowJs": true,
|
||||
"allowJs": false,
|
||||
"lib": ["dom", "ES2019", "ES2022.Error"],
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
|
||||
Reference in New Issue
Block a user