Webpack: How to export JS file without module -
i have js file looks this:
self.monacoenvironment = { baseurl: cdn_host + '/javascripts' }; importscripts('/javascripts/vs/base/worker/workermain.js'); in webpack.config, have cdn_host defined:
new webpack.defineplugin({ 'cdn_host': json.stringify(process.env.cdn_host || '') }), enter code here i export file, have cdn_host replaced value here, not want file wrapped in module (e.g, "webpackjsonp")
if use file-loader copy file module definitions, not replace cdn_host.
if use babel-loader, replace cdn_host add module definitions.
how can use defineplugin not use modules?
i managed without using defineplugin. instead, used file-loader chained string-replace-loader. string-replace-loader equivalent defineplugin purposes.
loaders: [ "file-loader?name=./filetoexport.js", { loader: "string-replace-loader", query: { search: 'cdn_host', replace: json.stringify(process.env.cdn_host || '') } }, ]
Comments
Post a Comment