16 changed files with 1009 additions and 2871 deletions
@ -0,0 +1,28 @@ |
|||||
|
import { build } from 'esbuild'; |
||||
|
import htmlPlugin from '@chialab/esbuild-plugin-html'; |
||||
|
import { compress } from 'esbuild-plugin-compress'; |
||||
|
|
||||
|
build({ |
||||
|
entryPoints: ['src/index.html'], |
||||
|
chunkNames: '[name]-[hash]', |
||||
|
logLevel: "warning", |
||||
|
outdir: "./build", |
||||
|
bundle: true, |
||||
|
treeShaking: true, |
||||
|
minify: true, |
||||
|
write: false, |
||||
|
format: "esm", |
||||
|
target: "es6", |
||||
|
platform: "browser", |
||||
|
sourcemap: "linked", |
||||
|
loader: {".ts": "tsx"}, |
||||
|
plugins: [ |
||||
|
htmlPlugin(), |
||||
|
compress({ |
||||
|
brotli: false, |
||||
|
gzip: true |
||||
|
}) |
||||
|
] |
||||
|
}) |
||||
|
.then(() => console.log("⚡ Done")) |
||||
|
.catch(() => process.exit(1)); |
||||
File diff suppressed because it is too large
@ -1,14 +1,15 @@ |
|||||
<!DOCTYPE html> |
<!DOCTYPE html> |
||||
<html> |
<html> |
||||
|
|
||||
<head> |
<head> |
||||
<meta charset="UTF-8"> |
<meta charset="UTF-8"> |
||||
<title>Avalonia XAML previewer web edition</title> |
<title>Avalonia XAML previewer web edition</title> |
||||
</head> |
</head> |
||||
|
|
||||
<body> |
<body> |
||||
<div id="app"> |
<div id="app"> |
||||
<center>Loading...</center> |
<center>Loading...</center> |
||||
</div> |
</div> |
||||
<noscript>JavaScript is required</noscript> |
<noscript>JavaScript is required</noscript> |
||||
|
<script src="index.tsx"></script> |
||||
</body> |
</body> |
||||
</html> |
</html> |
||||
@ -1,116 +0,0 @@ |
|||||
const webpack = require('webpack'); |
|
||||
const path = require('path'); |
|
||||
const LiveReloadPlugin = require('webpack-livereload-plugin'); |
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin'); |
|
||||
const CompressionPlugin = require('compression-webpack-plugin'); |
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); |
|
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); |
|
||||
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); |
|
||||
const prod = process.env.NODE_ENV == 'production'; |
|
||||
|
|
||||
class Printer { |
|
||||
apply(compiler) { |
|
||||
compiler.hooks.afterEmit.tap("Printer", ()=> console.log("Build completed at " + new Date().toString())); |
|
||||
compiler.hooks.watchRun.tap("Printer", ()=> console.log("Watch triggered at " + new Date().toString())); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
const config = { |
|
||||
stats: { |
|
||||
errorDetails: true |
|
||||
}, |
|
||||
entry: { |
|
||||
bundle: './src/index.tsx' |
|
||||
}, |
|
||||
output: { |
|
||||
path: path.resolve(__dirname, 'build'), |
|
||||
publicPath: '/', |
|
||||
filename: '[name].[chunkhash].js' |
|
||||
}, |
|
||||
performance: { hints: false }, |
|
||||
mode: prod ? "production" : "development", |
|
||||
module: { |
|
||||
rules: [ |
|
||||
{ |
|
||||
enforce: "pre", |
|
||||
test: /\.js$/, |
|
||||
loader: "source-map-loader", |
|
||||
exclude: [ |
|
||||
path.resolve(__dirname, 'node_modules/mobx-state-router') |
|
||||
] |
|
||||
}, |
|
||||
{ |
|
||||
"oneOf": [ |
|
||||
{ |
|
||||
test: /\.(ts|tsx)$/, |
|
||||
exclude: /node_modules/, |
|
||||
use: 'ts-loader' |
|
||||
}, |
|
||||
{ |
|
||||
test: /\.css$/, |
|
||||
use: [ |
|
||||
MiniCssExtractPlugin.loader, |
|
||||
'css-loader' |
|
||||
] |
|
||||
}, |
|
||||
{ |
|
||||
test: /\.(jpg|png)$/, |
|
||||
use: { |
|
||||
loader: "url-loader", |
|
||||
options: { |
|
||||
limit: 25000, |
|
||||
}, |
|
||||
}, |
|
||||
}, |
|
||||
{ |
|
||||
test: /.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/, |
|
||||
use: [{ |
|
||||
loader: 'file-loader', |
|
||||
options: { |
|
||||
name: '[name].[ext]', |
|
||||
outputPath: 'fonts/', // where the fonts will go
|
|
||||
} |
|
||||
}] |
|
||||
}, |
|
||||
{ |
|
||||
loader: require.resolve('file-loader'), |
|
||||
exclude: [/\.(js|jsx|mjs|tsx|ts)$/, /\.html$/, /\.json$/], |
|
||||
options: { |
|
||||
name: 'assets/[name].[hash:8].[ext]', |
|
||||
}, |
|
||||
}] |
|
||||
}, |
|
||||
|
|
||||
] |
|
||||
}, |
|
||||
devtool: "source-map", |
|
||||
resolve: { |
|
||||
modules: [path.resolve(__dirname, 'node_modules')], |
|
||||
plugins: [new TsconfigPathsPlugin({ configFile: "./tsconfig.json", logLevel: 'info' })], |
|
||||
extensions: ['.ts', '.tsx', '.js', '.json'], |
|
||||
alias: { |
|
||||
'src': path.resolve(__dirname, 'src') |
|
||||
} |
|
||||
}, |
|
||||
plugins: |
|
||||
[ |
|
||||
new Printer(), |
|
||||
new CleanWebpackPlugin({ |
|
||||
cleanAfterEveryBuildPatterns: ['dist'] |
|
||||
}), |
|
||||
new MiniCssExtractPlugin({ |
|
||||
filename: "[name].[chunkhash]h" + |
|
||||
".css", |
|
||||
chunkFilename: "[id].[chunkhash].css" |
|
||||
}), |
|
||||
new LiveReloadPlugin({appendScriptTag: !prod}), |
|
||||
new HtmlWebpackPlugin({ |
|
||||
template: path.resolve(__dirname, './src/index.html'), |
|
||||
filename: 'index.html' //relative to root of the application
|
|
||||
}), |
|
||||
new CompressionPlugin({ |
|
||||
test: /(\?.*)?$/i |
|
||||
}) |
|
||||
] |
|
||||
}; |
|
||||
module.exports = config; |
|
||||
@ -0,0 +1,16 @@ |
|||||
|
require("esbuild").build({ |
||||
|
entryPoints: [ |
||||
|
"./modules/Avalonia.ts", |
||||
|
"./modules/Storage.ts" |
||||
|
], |
||||
|
outdir: "../wwwroot", |
||||
|
bundle: true, |
||||
|
minify: true, |
||||
|
format: "esm", |
||||
|
target: "es2016", |
||||
|
platform: "browser", |
||||
|
sourcemap: "linked", |
||||
|
loader: {".ts": "ts"} |
||||
|
}) |
||||
|
.then(() => console.log("⚡ Done")) |
||||
|
.catch(() => process.exit(1)); |
||||
@ -0,0 +1,5 @@ |
|||||
|
export { DpiWatcher } from "./Avalonia/DpiWatcher" |
||||
|
export { InputHelper } from "./Avalonia/InputHelper" |
||||
|
export { NativeControlHost } from "./Avalonia/NativeControlHost" |
||||
|
export { SizeWatcher } from "./Avalonia/SizeWatcher" |
||||
|
export { SKHtmlCanvas } from "./Avalonia/SKHtmlCanvas" |
||||
@ -1,5 +0,0 @@ |
|||||
export { DpiWatcher } from "./DpiWatcher" |
|
||||
export { InputHelper } from "./InputHelper" |
|
||||
export { NativeControlHost } from "./NativeControlHost" |
|
||||
export { SizeWatcher } from "./SizeWatcher" |
|
||||
export { SKHtmlCanvas } from "./SKHtmlCanvas" |
|
||||
@ -0,0 +1 @@ |
|||||
|
export { StorageProvider } from "./Storage/StorageProvider" |
||||
@ -1,16 +1,13 @@ |
|||||
{ |
{ |
||||
"name": "avalonia.web", |
"name": "avalonia.web", |
||||
"scripts": { |
"scripts": { |
||||
"dist": "cross-env NODE_ENV=production webpack", |
"prebuild": "tsc -noEmit", |
||||
"build": "cross-env NODE_ENV=development webpack" |
"build": "node build.js" |
||||
}, |
}, |
||||
"devDependencies": { |
"devDependencies": { |
||||
"@types/emscripten": "^1.39.6", |
"@types/emscripten": "^1.39.6", |
||||
"@types/wicg-file-system-access": "^2020.9.5", |
"@types/wicg-file-system-access": "^2020.9.5", |
||||
"cross-env": "^7.0.3", |
|
||||
"ts-loader": "^9.3.1", |
|
||||
"typescript": "^4.7.4", |
"typescript": "^4.7.4", |
||||
"webpack": "^5.73.0", |
"esbuild": "^0.15.7" |
||||
"webpack-cli": "^4.10.0" |
|
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,40 +0,0 @@ |
|||||
const path = require('path'); |
|
||||
const prod = process.env.NODE_ENV == 'production'; |
|
||||
|
|
||||
module.exports = { |
|
||||
mode: prod ? "production" : "development", |
|
||||
devtool: 'source-map', |
|
||||
target: ["web", "es2020"], |
|
||||
entry: { |
|
||||
avalonia: './modules/Avalonia/Avalonia.ts', |
|
||||
avaloniaStorage: { |
|
||||
import: './modules/Storage/StorageProvider.ts', |
|
||||
dependOn: 'avalonia', |
|
||||
} |
|
||||
}, |
|
||||
output: { |
|
||||
filename: '[name].js', |
|
||||
path: path.resolve(__dirname, '../wwwroot'), |
|
||||
library: { |
|
||||
type: 'module', |
|
||||
}, |
|
||||
}, |
|
||||
module: { |
|
||||
rules: [ |
|
||||
{ |
|
||||
test: /\.tsx?$/, |
|
||||
use: 'ts-loader', |
|
||||
exclude: /node_modules/, |
|
||||
}, |
|
||||
], |
|
||||
}, |
|
||||
resolve: { |
|
||||
extensions: ['.ts', '.js'], |
|
||||
}, |
|
||||
optimization: { |
|
||||
minimize: false |
|
||||
}, |
|
||||
experiments: { |
|
||||
outputModule: true, |
|
||||
} |
|
||||
}; |
|
||||
Loading…
Reference in new issue