import utils from "./Utils";
(function flexible(window, document) {
var docEl = document.documentElement;
var dpr = window.devicePixelRatio || 1;
function setBodyFontSize() {
if (document.body) {
document.body.style.fontSize = 12 * dpr + "px";
} else {
document.addEventListener("DOMContentLoaded", setBodyFontSize);
}
}
setBodyFontSize();
function setRemUnit() {
console.log("flexible setRemUnit ", utils.getDeviceOs());
var rem;
if (utils.getDeviceOs().isTablet) {
rem = utils.isOrientation() ? (docEl.clientWidth / 800) * 36 : (docEl.clientWidth / 423) * 36;
} else {
rem = window.screen.width > 500 ? (docEl.clientWidth / 677) * 36 : docEl.clientWidth / 10;
}
docEl.style.fontSize = rem + "px";
}
setRemUnit();
window.addEventListener("resize", setRemUnit);
window.addEventListener("pageshow", function (e) {
if (e.persisted) {
setRemUnit();
}
});
if (dpr >= 2) {
var fakeBody = document.createElement("body");
var testElement = document.createElement("div");
testElement.style.border = ".5px solid transparent";
fakeBody.appendChild(testElement);
docEl.appendChild(fakeBody);
if (testElement.offsetHeight === 1) {
docEl.classList.add("hairlines");
}
docEl.removeChild(fakeBody);
}
})(window, document);
import "./utils/amfe-flexible.js";
new Vue({
router,
store,
i18n,
render: (h) => h(App),
}).$mount("#app");
const path = require("path");
const resolve = (dir) => {
return path.join(__dirname, dir);
};
module.exports = {
publicPath: "./",
assetsDir: "static",
outputDir: "h5_001",
productionSourceMap: false,
devServer: {
overlay: {
warnings: false,
errors: false
}
},
chainWebpack: (config) => {
config.output.filename("static/js/[name].[hash].js").end();
config.devServer.disableHostCheck(true);
config
.entry("app")
.clear()
.add(`./src/pages/main.js`);
},
css: {
extract: process.env.NODE_ENV === "production",
sourceMap: false,
requireModuleExtension: true,
loaderOptions: {
less: {
lessOptions: {
modifyVars: {
},
},
},
postcss: {
plugins: [
require("postcss-pxtorem")({
rootValue: 36,
propList: ["*"],
minPixelValue: 12,
unitPrecision: 6,
}),
],
},
},
},
pluginOptions: {
"style-resources-loader": {
preProcessor: "less",
patterns: [resolve("./src/assets/style/theme-device.less")],
},
},
};