forked from mystiq/hydrogen-web
WIP
This commit is contained in:
parent
ceb0b5793b
commit
6add3f1da3
2 changed files with 25 additions and 15 deletions
|
@ -2,7 +2,8 @@ const cssvariables = require("postcss-css-variables");
|
||||||
const flexbugsFixes = require("postcss-flexbugs-fixes");
|
const flexbugsFixes = require("postcss-flexbugs-fixes");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const version = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8")).version;
|
const manifest = require("./package.json");
|
||||||
|
const version = manifest.version;
|
||||||
|
|
||||||
const commonOptions = {
|
const commonOptions = {
|
||||||
logLevel: "info",
|
logLevel: "info",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const mergeOptions = require('merge-options').bind({concatArrays: true});
|
const mergeOptions = require('merge-options').bind({concatArrays: true});
|
||||||
const commonOptions = require("./vite.common-config.js");
|
const commonOptions = require("./vite.common-config.js");
|
||||||
|
const manifest = require("./package.json");
|
||||||
|
|
||||||
const srcDir = path.join(__dirname, "src/");
|
const srcDir = path.join(__dirname, "src/");
|
||||||
const modulesDir = path.join(srcDir, "node_modules/");
|
const modulesDir = path.join(srcDir, "node_modules/");
|
||||||
|
@ -8,19 +9,19 @@ const mocksDir = path.join(srcDir, "mocks/");
|
||||||
const fixturesDir = path.join(srcDir, "fixtures/");
|
const fixturesDir = path.join(srcDir, "fixtures/");
|
||||||
|
|
||||||
const commonOutput = {
|
const commonOutput = {
|
||||||
manualChunks: (id) => {
|
// manualChunks: (id) => {
|
||||||
if (id.endsWith("/lib.ts")) {
|
// if (id.endsWith("/lib.ts")) {
|
||||||
console.log(id, arguments);
|
// console.log(id, arguments);
|
||||||
return "es/lib";
|
// return "es/lib";
|
||||||
}
|
// }
|
||||||
if (id.startsWith(srcDir)) {
|
// if (id.startsWith(srcDir)) {
|
||||||
const idPath = id.substring(srcDir.length);
|
// const idPath = id.substring(srcDir.length);
|
||||||
const pathWithoutExt = idPath.substring(0, idPath.lastIndexOf("."));
|
// const pathWithoutExt = idPath.substring(0, idPath.lastIndexOf("."));
|
||||||
return pathWithoutExt;
|
// return pathWithoutExt;
|
||||||
} else {
|
// } else {
|
||||||
return "index";
|
// return "index";
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
chunkFileNames: `[format]/[name].js`,
|
chunkFileNames: `[format]/[name].js`,
|
||||||
assetFileNames: `assets/[name][extname]`,
|
assetFileNames: `assets/[name][extname]`,
|
||||||
// important to preserve export names of every module
|
// important to preserve export names of every module
|
||||||
|
@ -29,6 +30,9 @@ const commonOutput = {
|
||||||
preferConst: true,
|
preferConst: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const externalDependencies = Object.keys(manifest.dependencies).concat(Object.keys(manifest.devDependencies)).filter(d => d !== "@matrix-org/olm").map(d => path.join(__dirname, "node_modules", d));
|
||||||
|
console.log("external", externalDependencies);
|
||||||
|
|
||||||
export default mergeOptions(commonOptions, {
|
export default mergeOptions(commonOptions, {
|
||||||
root: "src/",
|
root: "src/",
|
||||||
plugins: [
|
plugins: [
|
||||||
|
@ -51,7 +55,12 @@ export default mergeOptions(commonOptions, {
|
||||||
treeshake: false,
|
treeshake: false,
|
||||||
external: (id, parentId) => {
|
external: (id, parentId) => {
|
||||||
const resolveId = (id.startsWith("./") || id.startsWith("../")) ? path.join(path.dirname(parentId), id) : id;
|
const resolveId = (id.startsWith("./") || id.startsWith("../")) ? path.join(path.dirname(parentId), id) : id;
|
||||||
return !resolveId.startsWith(srcDir) || resolveId.startsWith(mocksDir) || resolveId.startsWith(fixturesDir);
|
const external = externalDependencies.some(d => resolveId.startsWith(d));
|
||||||
|
if (external) {
|
||||||
|
console.log("external", resolveId);
|
||||||
|
}
|
||||||
|
return external;
|
||||||
|
//return !resolveId.startsWith(srcDir);// || resolveId.startsWith(mocksDir) || resolveId.startsWith(fixturesDir);
|
||||||
},
|
},
|
||||||
preserveEntrySignatures: "strict",
|
preserveEntrySignatures: "strict",
|
||||||
output: [
|
output: [
|
||||||
|
|
Loading…
Reference in a new issue