我正在尝试 npm 发布具有以下结构的 angular2 应用程序。
search-app
config
node_modules
src
api
--index.ts
--ping.ts
--search.ts
model
--index.ts
--model.ts
web
app
ping
--index.ts
--ping.css
--ping.html
--ping.ts
search
--index.ts
--search.css
--search.html
--search.ts
--app.css
--app.html
--app.module.ts
--app.ts
--index.html
--index.ts
package.json
tsconfig.json
现在,我的“npm run dist”命令是
"dist": "npm run rimraf -- dist && tsc src/index.ts src/web/index.ts src/model/index.ts -m commonjs --outDir dist --sourcemap --target es6 -d --pretty --noImplicitAny --experimentalDecorators --skipLibCheck"
运行 npm run dist 将产生以下 dist 目录。
search-app
dist
api
--*.d.ts
--*.js
model
--*.d.ts
--*.js
web
app
ping
--*.d.ts
--*.js
search
--*.d.ts
--*.js
--*.d.ts
--*.js
--index.d.ts
--index.js
关于如何在保持子目录结构的同时将 html 和 css 文件从 src/web 及其子目录复制到 dist/web 的任何建议?
我基本上是在寻找可以附加到我的 dist 命令以复制 html 和 css 文件的命令。我使用 OSX,但理想的命令是在 OSX 和 Windows 上都可以使用的命令。
要实现这个跨平台首先安装copyfiles包:
$ npm i -D copyfiles
然后在package.json
添加以下copy
脚本:
...
"scripts": {
...
"copy": "copyfiles -u 2 \"./src/web/**/*.{css,html}\" \"./dist/web/\""
},
...
copy
通过链接&& npm run copy
到现有dist
脚本的末尾来调用脚本,如以下示例所示:
...
"scripts": {
"dist": "npm run rimraf -- dist && tsc src/index.ts src/web/index.ts src/model/index.ts -m commonjs --outDir dist --sourcemap --target es6 -d --pretty --noImplicitAny --experimentalDecorators --skipLibCheck && npm run copy",
"copy": "copyfiles -u 2 \"./src/web/**/*.{css,html}\" \"./dist/web/\""
},
...
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句