2022-08-04 14:12:11 +08:00
|
|
|
import resolve from "@rollup/plugin-node-resolve";
|
|
|
|
import commonjs from "@rollup/plugin-commonjs";
|
|
|
|
import jsonPlugin from "@rollup/plugin-json";
|
|
|
|
import fs from "fs";
|
|
|
|
import path from "path";
|
2019-12-19 10:42:57 +08:00
|
|
|
|
2022-08-04 14:12:11 +08:00
|
|
|
const sandboxBundle = fs.readFileSync(
|
|
|
|
path.resolve("./node_modules/doric/bundle/doric-sandbox.js"),
|
|
|
|
"utf-8"
|
|
|
|
);
|
2019-12-19 10:42:57 +08:00
|
|
|
|
2022-08-04 14:12:11 +08:00
|
|
|
const doricLibBundle = fs.readFileSync(
|
|
|
|
path.resolve("./node_modules/doric/bundle/doric-lib.js"),
|
|
|
|
"utf-8"
|
|
|
|
);
|
2019-12-19 10:42:57 +08:00
|
|
|
|
2019-12-19 10:58:46 +08:00
|
|
|
const builtinScript = `
|
2022-08-04 14:12:11 +08:00
|
|
|
const Environment = {
|
|
|
|
platform:"web"
|
|
|
|
};
|
2019-12-19 10:58:46 +08:00
|
|
|
/**++++++++SandBox++++++++*/
|
|
|
|
${sandboxBundle}
|
|
|
|
/**--------SandBox--------*/
|
|
|
|
|
|
|
|
/**++++++++Lib++++++++*/
|
2019-12-19 13:07:33 +08:00
|
|
|
Reflect.apply(doric.jsRegisterModule,this,["doric",Reflect.apply(function(__module){(function(module,exports,require){
|
2019-12-19 10:58:46 +08:00
|
|
|
${doricLibBundle}
|
|
|
|
})(__module,__module.exports,doric.__require__);
|
|
|
|
return __module.exports;
|
|
|
|
},this,[{exports:{}}])]);
|
|
|
|
/**--------Lib--------*/
|
2022-08-04 14:12:11 +08:00
|
|
|
`;
|
2019-12-19 10:58:46 +08:00
|
|
|
|
2019-12-19 10:42:57 +08:00
|
|
|
export default {
|
2022-08-04 14:12:11 +08:00
|
|
|
input: `build/index.js`,
|
|
|
|
output: {
|
|
|
|
format: "iife",
|
|
|
|
name: "doric_web",
|
|
|
|
file: `dist/index.js`,
|
|
|
|
sourcemap: true,
|
|
|
|
banner: builtinScript,
|
|
|
|
globals: {
|
|
|
|
doric: "doric_lib",
|
|
|
|
"doric/src/runtime/sandbox": "doric",
|
2019-12-19 10:42:57 +08:00
|
|
|
},
|
2022-08-04 14:12:11 +08:00
|
|
|
},
|
|
|
|
plugins: [resolve({ mainFields: ["jsnext"] }), commonjs(), jsonPlugin()],
|
|
|
|
external: ["axios", "reflect-metadata", "doric"],
|
|
|
|
onwarn: function (warning) {
|
|
|
|
if (warning.code === "THIS_IS_UNDEFINED") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
console.warn(warning.message);
|
|
|
|
},
|
|
|
|
};
|