Commit 6fe7ee36 authored by 邱旭's avatar 邱旭

mfk

parent 8e2b7d61
node_modules
npm-debug.log
.DS_Store
*.zip
yarn-error.log
yarn.lock
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="HtmlRequiredAltAttribute" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/testspark317.iml" filepath="$PROJECT_DIR$/.idea/testspark317.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
const babel = require('@babel/core');
const HtmlWebpackPlugin = require("html-webpack-plugin");
class HtmlJsToES5Plugin {
process(htmlPluginData) {
return new Promise(function (resolve) {
const scriptRegExp = /<script>(.|\n)*?<\/script>/gi;
htmlPluginData.html = htmlPluginData.html.replace(scriptRegExp, function (match) {
const code = match.replace("<script>", "").replace("</script>", "");
const es5Code = babel.transform(code, { 'presets': ['@babel/preset-env'] }).code;
return `<script>${es5Code}</script>`;
});
htmlPluginData.plugin.options.inject = false;
resolve();
});
};
apply(compiler){
compiler.hooks.compilation.tap('HtmlJsToES5Plugin', (compilation) => {
HtmlWebpackPlugin.getHooks(compilation).afterTemplateExecution.tapAsync(
"HtmlJsToES5Plugin",
async (html, cb) => {
await this.process(html);
cb(null, html);
}
);
});
}
}
exports.default = HtmlJsToES5Plugin;
module.exports = exports['default'];
...@@ -9,6 +9,8 @@ const TerserPlugin = require("terser-webpack-plugin"); ...@@ -9,6 +9,8 @@ const TerserPlugin = require("terser-webpack-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"); const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const ProgressBarPlugin = require("progress-bar-webpack-plugin"); const ProgressBarPlugin = require("progress-bar-webpack-plugin");
const HtmlJsToES5Plugin = require("./HtmlJsToES5Plugin");
module.exports = function (isProd) { module.exports = function (isProd) {
const appPath = process.cwd(); const appPath = process.cwd();
...@@ -142,6 +144,7 @@ module.exports = function (isProd) { ...@@ -142,6 +144,7 @@ module.exports = function (isProd) {
// cleanOnceBeforeBuildPatterns:['**/*', 'dist'] // 这里不用写 是默认的。 路径会根据output 输出的路径去清除 // cleanOnceBeforeBuildPatterns:['**/*', 'dist'] // 这里不用写 是默认的。 路径会根据output 输出的路径去清除
}), }),
new ProgressBarPlugin(), new ProgressBarPlugin(),
new HtmlJsToES5Plugin(),
].filter(Boolean), ].filter(Boolean),
optimization: { optimization: {
minimize: isProd, minimize: isProd,
......
...@@ -9,6 +9,11 @@ ...@@ -9,6 +9,11 @@
<script src="//yun.duiba.com.cn/js-libs/rem/1.1.3/rem.min.js"></script> <script src="//yun.duiba.com.cn/js-libs/rem/1.1.3/rem.min.js"></script>
<script src="//yun.duiba.com.cn/h5/lib/zepto.min.js"></script> <script src="//yun.duiba.com.cn/h5/lib/zepto.min.js"></script>
<script> <script>
let a = () => {
console.log(a);
}
function getApp() { function getApp() {
return { return {
cloud: {}, cloud: {},
...@@ -17,7 +22,7 @@ ...@@ -17,7 +22,7 @@
} }
} }
let testFunc = ()=>{ let testFunc = () => {
const str = 'hello'; const str = 'hello';
console.log(str) console.log(str)
} }
...@@ -34,7 +39,7 @@ ...@@ -34,7 +39,7 @@
CFG.appID = '${APPID}'; CFG.appID = '${APPID}';
if (!getUrlParam("appID")) { if (!getUrlParam("appID")) {
alert("【警告】检测到活动url中没有appID参数\n缺少该参数会导致埋点、分享、app信息获取错误。") // alert("【警告】检测到活动url中没有appID参数\n缺少该参数会导致埋点、分享、app信息获取错误。")
} }
</script> </script>
</head> </head>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment