2015-06-12 26 views
1

我需要刪除所有'嚴格模式'。下面的代碼運行沒有錯誤,但我的'嚴格模式';不改變;如何擺脫使用嚴格的使用JavaScript的gulp文件

gulp.task('bundle', function() { 
var bundled = bundle(bundler()) 
if (!production) return bundled; 
    return bundled 
.pipe(buffer()) 
.pipe(replace(/"use strict"'/g, ';')) // problem line 

.pipe(plugins.uglify()) 
.pipe(plugins.rename({ 
    suffix: '.min' 
})) 

.pipe(gulp.dest('dist/app')); 
}); 
+0

這個想法是使用的Drupal 7的總js文件的選擇,因爲第三方JS是在「使用嚴格的」打破對我很有用,所以感謝發帖! – artfulrobot

回答

5

看起來像你的正則表達式有一個寬鬆的單引號。

.pipe(replace(/"use strict"'/g, ';')) 
        here ----^ 

這個規則表達式將匹配'use strict'"use strict"

/('|")use strict\1/g