mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
feat(client): use shared config which also fixes production builds
This commit is contained in:
parent
dbe9e43ff1
commit
e7e763435e
@ -20,38 +20,15 @@ async function register(app: express.Application) {
|
|||||||
if (env.isDev()) {
|
if (env.isDev()) {
|
||||||
const webpack = (await import("webpack")).default;
|
const webpack = (await import("webpack")).default;
|
||||||
const webpackMiddleware = (await import("webpack-dev-middleware")).default;
|
const webpackMiddleware = (await import("webpack-dev-middleware")).default;
|
||||||
|
const productionConfig = (await import("../../webpack.config.js")).default;
|
||||||
|
|
||||||
const frontendCompiler = webpack({
|
const frontendCompiler = webpack({
|
||||||
mode: "development",
|
mode: "development",
|
||||||
entry: {
|
entry: productionConfig.entry,
|
||||||
setup: './src/public/app/setup.js',
|
module: productionConfig.module,
|
||||||
mobile: './src/public/app/mobile.js',
|
resolve: productionConfig.resolve,
|
||||||
desktop: './src/public/app/desktop.js',
|
devtool: productionConfig.devtool,
|
||||||
},
|
target: productionConfig.target
|
||||||
devtool: 'source-map',
|
|
||||||
target: 'electron-renderer',
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.ts$/,
|
|
||||||
use: [{
|
|
||||||
loader: 'ts-loader',
|
|
||||||
options: {
|
|
||||||
configFile: path.join(srcRoot, "..", "tsconfig.webpack.json")
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
exclude: /node_modules/,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
extensions: ['.ts', '.js'],
|
|
||||||
extensionAlias: {
|
|
||||||
".js": [".js", ".ts"],
|
|
||||||
".cjs": [".cjs", ".cts"],
|
|
||||||
".mjs": [".mjs", ".mts"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use(`/${assetPath}/app`, webpackMiddleware(frontendCompiler));
|
app.use(`/${assetPath}/app`, webpackMiddleware(frontendCompiler));
|
||||||
|
@ -15,6 +15,28 @@ export default {
|
|||||||
path: path.resolve(rootDir, 'src/public/app-dist'),
|
path: path.resolve(rootDir, 'src/public/app-dist'),
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
},
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.ts$/,
|
||||||
|
use: [{
|
||||||
|
loader: 'ts-loader',
|
||||||
|
options: {
|
||||||
|
configFile: path.join(rootDir, "tsconfig.webpack.json")
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
exclude: /node_modules/,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.ts', '.js'],
|
||||||
|
extensionAlias: {
|
||||||
|
".js": [".js", ".ts"],
|
||||||
|
".cjs": [".cjs", ".cts"],
|
||||||
|
".mjs": [".mjs", ".mts"]
|
||||||
|
}
|
||||||
|
},
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
target: 'electron-renderer',
|
target: 'electron-renderer',
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user