线上打包环境才加载外部cdn,开发模式不加载cdn

This commit is contained in:
xing 2020-07-02 10:53:26 +08:00
parent 2a35a5d994
commit c526ea7d4e
2 changed files with 13 additions and 1 deletions

View File

@ -5,6 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<% if(htmlWebpackPlugin.options.isProd){ %>
<link href="https://cdn.staticfile.org/element-ui/2.13.2/theme-chalk/index.css" rel="stylesheet">
<link href="https://cdn.staticfile.org/nprogress/0.2.0/nprogress.css" rel="stylesheet">
<link href="https://cdn.staticfile.org/quill/1.3.7/quill.core.min.css" rel="stylesheet">
@ -20,7 +21,8 @@
<script src="https://cdn.staticfile.org/element-ui/2.13.2/index.js"></script>
<script src="https://cdn.staticfile.org/quill/1.3.7/quill.min.js"></script>
<script src="vue-quill-editor.js"></script>
<title><%= htmlWebpackPlugin.options.title %></title>
<% } %>
<title><%= htmlWebpackPlugin.options.isProd ? '' :'dev -' %> 后台管理系统</title>
</head>
<body>
<noscript>

View File

@ -20,10 +20,20 @@ module.exports = {
nprogress: 'NProgress',
'vue-quill-editor': 'VueQuillEditor'
})
config.plugin('html').tap(args => {
args[0].isProd = true
return args
})
})
// 设置开发环境的main.js
config.when(process.env.NODE_ENV === 'development', config => {
config.entry('add').clear().add('./src/main-dev.js')
config.plugin('html').tap(args => {
args[0].isProd = false
return args
})
})
}
}