问题描述
我有一个angular 2应用程序,其中定义了Typescript编译器选项以生成单个 outFile ,即Scripts1.js和Scripts1.js.map
I have a angular 2 application in which typescript compiler options is defined to generate a single outFile which is Scripts1.js and Scripts1.js.map
现在进入我的index.html
Now in my index.html
<script src="Scripts/Script1.js"></script>
<script>
System.config({
packages: {
'V1/components/main': {
format: 'register',
defaultExtension: 'js',
defaultJSExtensions: true
}
}
});
debugger;
//System.import('Scripts/main')
System.import('V1/components/main')
.then(null, console.error.bind(console));
</script>
现在哪个工作正常?如何使用gulp将其丑化
Which is working fine now How to uglify this using gulp
我的gulpFile.js
My gulpFile.js
gulp.task('MinifyBundled', function () {
console.log('testiang');
return gulp.src(config.src2)
.pipe(uglify())
.pipe(gulp.dest('app/'));
})
现在,当我包含
<script src="app/Script1.js"></script>
此缩小文件不起作用,控制台中没有错误.我猜想我在地图映射时丢失了地图文件.我尝试过了
this minified file it is not working and no errors in console . I guess I'm missing map files while uglifying . I tried this
gulp.task('MinifyBundled', function () {
console.log('testiang');
return gulp.src(config.src2)
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(uglify())
.pipe(sourcemaps.write('app/'))
.pipe(gulp.dest('app/'));
})
P.S:请不要建议任何其他捆绑或缩小工具,我已经厌倦了所有
P.S : Please don't suggest any other bundling or minification tools, I'm sick of all
推荐答案
尝试将gugle uglify的mangle选项设置为false.IE.pipe(uglify(),{mangle:false})
Try gulp uglify with mangle option set as false.i.e.pipe(uglify(), {mangle : false})
这篇关于如何使用gulp uglify在angular 2中加载缩小的文件? (最小化TYpescript捆绑文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!