我的javascript文件之一是使用存档模板语法:
const deliveryClient = new DeliveryClient({
enablePreviewMode: <%= options.enablePreviewMode %>,
projectId: '<%= options.projectId %>',
previewApiKey: '<%= options.previewApiKey %>',
defaultLanguage: '<%= options.defaultLanguage %>',
enableAdvancedLogging: <%= options.enableAdvancedLogging %>,
baseUrl: '<%= options.baseUrl %>',
typeResolvers: typeResolvers
});但是当我运行rollup -c时,我得到了一个“意外令牌”错误。有没有一种方法可以告诉rollup忽略一些代码行(只需将其放在输出文件中)?
或者,在RollupJS中是否有其他/更好的方法来处理提交模板语法?
我只想把上面的代码片段放到我的最后输出中!
发布于 2018-06-04 13:02:36
我通过使用汇总-插件-替换插件修复了它。
在我的javascript中,我将代码更改为:
const deliveryClient = new DeliveryClient('KENTICOOPTIONS');在rollup.config.js中,我添加了具有以下配置的插件:
replace({
include: 'lib/templates/plugin.template.js',
KENTICOOPTIONS: '<%= serialize(options) %>'
})因此,这给出了以下的最终输出:
const deliveryClient = new DeliveryClient('<%= serialize(options) %>');这正是我所需要的!
https://stackoverflow.com/questions/50679507
复制相似问题