gruntjs - 如何使用 GruntJs Terser JS Minify 创建 Sourcemap
问题描述
我正在使用 Terser for Gruntjs 来缩小 js 文件。我希望能够创建一个源映射,但我不知道如何将我在选项部分(https://www.npmjs.com/package/terser#source-map-options)中看到的示例转换为我的 gruntfile .js。
这是我正在缩小的部分,我添加了我认为 sourceMap 选项所在的部分:
grunt.initConfig({
terser: {
pages: {
options: {
mangle: {
properties: false
},
sourceMap: {
// source map options goes here I think but not certain what
}
},
files: [
{ expand: true,
src: '**/*.js',
dest: 'wwwroot/js',
cwd: 'wwwroot/js',
ext: '.min.js'
}
]
}
}
});
我在任何地方都找不到 gruntjs 示例,因此任何输入或帮助都会很棒
解决方案
我找到了答案并进行了测试。请注意以下sourceMap
条目options
:
grunt.initConfig({
terser: {
pages: {
options: {
mangle: {
properties: false
},
sourceMap: true
},
files: [
{ expand: true,
src: '**/*.js',
dest: 'wwwroot/js',
cwd: 'wwwroot/js',
ext: '.min.js'
}
]
}
}
});
推荐阅读
- gradle - 当构建脚本中的任务定义更改时,Gradle 是否应该使其任务缓存无效?
- java - 为什么这会给我一个错误(多线程或 ArrayList)?
- python - 使用字典映射后如何将数据框中的列更改为字符串
- r - 你如何循环 n 列并使用条件?
- python - 在 Python 中动态更改列名
- java - 通过 JNI NewObject 创建实例时 jvm.dll 中出现异常 0xC0000005
- c - 如何使用 gsasl gssapi 对 Active Directory 进行身份验证?
- python - 使用 Selenium webdriver 模块时 Firefox 浏览器无法打开
- python - 为什么在 for 循环中使用 yield
- asp.net - 从 asp.net 中的 bootstrap-datepicker 读取日期