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