[英]How to build to output folder when the typescript files are located in './src'
What I have: 我有的:
./src/myfile.ts
./test/mytest.spec.ts
And tsc should create a javascript ( myfile.js
) and definition file ( myfile.d.ts
) in the ./build
location. tsc应该在
./build
位置创建一个javascript( myfile.js
)和定义文件( myfile.d.ts
)。
My tsconfig.ts: 我的tsconfig.ts:
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"rootDir": ".",
"outDir": "./build",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"declaration": true
},
"files": [
"./src/index.ts"
],
"exclude": [
".vscode",
".git",
"build",
"node_modules",
"test"
],
"compileOnSave": false,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
But this config file generates the myfile.js
in the ./build/src/
sub-folder. 但是,此配置文件在
./build/src/
子文件夹中生成myfile.js
。
Note that I cannot use "rootDir": "./src"
because then the test folder is not compiled (which gives problems when running tests with karma + webpack?) 请注意,我不能使用
"rootDir": "./src"
因为这样就不会编译测试文件夹(使用karma + webpack运行测试时会出现问题吗?)
And tsc should create a javascript (myfile.js) and definition file (myfile.d.ts) in the ./build location.
tsc应该在./build位置创建一个javascript(myfile.js)和定义文件(myfile.d.ts)。
TypeScript is not nicely modeled to handle bundling . TypeScript没有很好地建模来处理捆绑 。 That is something you should use some other tool to do
那是你应该使用其他工具来做的事情
eg Webpack quickstart: https://basarat.gitbooks.io/typescript/content/docs/quick/browser.html 例如Webpack快速入门: https ://basarat.gitbooks.io/typescript/content/docs/quick/browser.html
Don't recommend out
/ outFile
: https://basarat.gitbooks.io/typescript/content/docs/tips/outFile.html 不要推荐
out
/ outFile
: https : outFile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.