0
我需要为html定义js的全局变量。 我有这个配置为webpack,我用这个问题DefinePlugin
,但它不起作用。如何在脚本webpack中定义变量
在webpack.config.js:
plugins: [
new webpack.DefinePlugin({
CUSTOMER_ID:'345345e34435344'
})
]
在index.html的
<!DOCTYPE html>
<html class="no-js" ng-app="app" ng-controller="MainCtrl as main">
<head>
<base href="/"><!-- Required for HTML5 -->
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
</head>
<script type="text/javascript">
console.log(CUSTOMER_ID); // undefined
</script>
</html>
谢谢!我试过了,但没有奏效(( – modelfak