我想从根和子域托管使用相同框架包的各种Angular2应用程序node_modules
:
domain.com
subdomain.domain.com
sub2.domain.com
资料夹结构
public_html
├── SUBDOMAINS
│ ├── sub2
│ │ ├── assets
│ │ └── src
│ └── subdomain
│ ├── assets
│ └── src
├── assets
├── boot.ts
├── index.html
├── node_modules
├── package.json
├── src
└── tsconfig.json
我希望能够利用根应用程序的资源,而不需要重复代码。
一种方法做,这是使用的WebPack和一饮而尽。您需要在tsconfig.json中将commonjs用作模块。
index.html
为每个项目目标文件夹创建文件,并将js/ts
捆绑软件作为脚本包含在其中。使用webpack开发服务器为每个项目的index.html文件监听不同的端口。
gulp.task("webpack-dev-serverWeb", function(callback) {
var myConfig = Object.create(webpackConfig);
new myWebpackDevServer(mywebpack(myConfig), {
publicPath: "/" + myConfig.output.publicPath,
stats: {
colors: true
}
}).listen(8080, "localhost", function(err) {
if (err) throw new gutil.PluginError("webpack-dev-server", err);
gutil.log("[webpack-dev-server]", "http://localhost:8080/webpack-dev-server/your_path_to_index.html_for_port_8080/index.html");
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句