Skip to content

Commit

Permalink
RDEV-5995 Fixed issues related with Hot Reload
Browse files Browse the repository at this point in the history
  • Loading branch information
alvesmiguel1 committed Nov 2, 2023
1 parent b978c94 commit 01b5c1b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ViewGenerator/ViewGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AssemblyTitle>ViewGenerator</AssemblyTitle>
<Product>ViewGenerator</Product>
<Description>Generates .NET View bindings from typescript</Description>
<Version>1.1.17</Version>
<Version>1.1.18</Version>
<PackageId>ViewGenerator</PackageId>
<PackageTags>Library</PackageTags>

Expand Down
19 changes: 11 additions & 8 deletions ViewGenerator/tools/webpack/Plugins/CommonConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import {
DtsExtension,
OutputDirectoryDefault,
JsChunkPlaceholder,
NamePlaceholder
NamePlaceholder,
IdPlaceholder,
CssExtension
} from "./Resources";
import { Dictionary, generateManifest, getCurrentDirectory, getFileName } from "./Utils";

Expand All @@ -22,7 +24,7 @@ import SassRuleSet from "../Rules/Sass";
import getTypeScriptRuleSet from "../Rules/TypeScript";
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";

let getCommonConfiguration = (libraryName: string, useCache: boolean, assemblyName?: string, pluginsRelativePath?: string, forHotReload?: boolean): Configuration => {
let getCommonConfiguration = (cacheName: string, libraryName: string, assemblyName?: string, pluginsRelativePath?: string, forHotReload?: boolean): Configuration => {

const entryMap: Dictionary<string> = {}
const outputMap: Dictionary<string> = {};
Expand Down Expand Up @@ -56,7 +58,7 @@ let getCommonConfiguration = (libraryName: string, useCache: boolean, assemblyNa
//
// E.g. if pluginsRelativePath is "../path/to/plugin/", we want to get the "plugin" part,
// and therefore we perform a pop twice, as the last portion will be an empty string.
pluginsAssembly = pathParts.pop() || pathParts.pop();
pluginsAssembly = pathParts.pop() || pathParts.pop();
}

const Configuration: Configuration = {
Expand Down Expand Up @@ -106,13 +108,13 @@ let getCommonConfiguration = (libraryName: string, useCache: boolean, assemblyNa
new Webpack.WatchIgnorePlugin({
paths: [ /scss\.d\.ts$/]
}),

new ForkTsCheckerWebpackPlugin({
typescript: {
diagnosticOptions: { syntactic: true, semantic: true, declaration: false, global: false },
}
}),

new MiniCssExtractPlugin({
filename: (chunkData) => {
const Directory: string = outputMap[chunkData.chunk.name];
Expand All @@ -121,7 +123,7 @@ let getCommonConfiguration = (libraryName: string, useCache: boolean, assemblyNa
}
return OutputDirectoryDefault + CssChunkPlaceholder;
},
chunkFilename: OutputDirectoryDefault + CssChunkPlaceholder
chunkFilename: OutputDirectoryDefault + (forHotReload ? IdPlaceholder + CssExtension : CssChunkPlaceholder)
}),

new WebpackManifestPlugin({
Expand All @@ -130,11 +132,12 @@ let getCommonConfiguration = (libraryName: string, useCache: boolean, assemblyNa
}),
]
};
if (useCache) {

if (cacheName) {
Configuration.cache ={
type: 'filesystem',
allowCollectingMemory: true,
name: cacheName
};
}

Expand Down
4 changes: 1 addition & 3 deletions ViewGenerator/tools/webpack/webpack_plugins.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import { getCurrentDirectory, sanitizeCommandLineParam } from "./Plugins/Utils";

const config = (env) => {

const standardConfig: Configuration = getCommonConfiguration("Plugins", env.useCache, sanitizeCommandLineParam(env.assemblyName));
const standardConfig: Configuration = getCommonConfiguration(env.useCache ? "pluginsCache" : "", "Plugins", sanitizeCommandLineParam(env.assemblyName));

(standardConfig.cache as any).name = "pluginsCache";

standardConfig.optimization = {
runtimeChunk: {
name: "PluginsRuntime"
Expand Down
12 changes: 7 additions & 5 deletions ViewGenerator/tools/webpack/webpack_views.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Configuration } from "webpack";

import getCommonConfiguration from "./Plugins/CommonConfiguration";
import { Dictionary, sanitizeCommandLineParam } from "./Plugins/Utils";
import {FullHashPlaceholder, IdPlaceholder, OutputDirectoryDefault, RuntimePlaceholder} from "./Plugins/Resources";
import { FullHashPlaceholder, IdPlaceholder, OutputDirectoryDefault, RuntimePlaceholder } from "./Plugins/Resources";

const config = (env) => {

Expand Down Expand Up @@ -38,10 +38,8 @@ const config = (env) => {

const sanitizedPluginsRelativePath: string = sanitizeCommandLineParam(env.pluginsRelativePath);

const standardConfig: Configuration = getCommonConfiguration("Views", env.useCache, sanitizeCommandLineParam(env.assemblyName), sanitizedPluginsRelativePath, env.forHotReload);
const standardConfig: Configuration = getCommonConfiguration(env.useCache ? "viewsCache" : "", "Views", sanitizeCommandLineParam(env.assemblyName), sanitizedPluginsRelativePath, env.forHotReload);

(standardConfig.cache as any).name = "viewsCache";

standardConfig.optimization = {
runtimeChunk: {
name: "ViewsRuntime"
Expand Down Expand Up @@ -88,7 +86,11 @@ const config = (env) => {
client: {
overlay: false
},
allowedHosts: "all"
allowedHosts: "all",
headers: {
"Access-Control-Allow-Origin": "*",
"Cache-Control": "no-store"
}
};
}

Expand Down

0 comments on commit 01b5c1b

Please sign in to comment.