Vue-cli 3.x can't find the js file after packing?

There is a rem.js under

src/assets/js

but I executed npm run build and sent a warning

clipboard.png

this is the main.js code:

//rem
import rem from "./assets/js/rem.js"
Vue.use(rem);

this is the rem.js code:

fnResize()
window.onresize = function () {
    fnResize()
}
function fnResize() {
    var deviceWidth = document.documentElement.clientWidth || window.innerWidth
    document.documentElement.style.fontSize = (deviceWidth / 3.75) + "px"
}

this is the vue.config.js code:

module.exports = {
    lintOnSave: false,
    baseUrl:"./",
    devServer: {
        port: 9001
    }
}

I feel fine. There are warnings all the time when packing.

May.06,2022

Brother, it's already obvious that you didn't put it export default in rem.js
like this

export default function(){
    fnResize()
    window.onresize = function () {
        fnResize()
    }
    function fnResize() {
        var deviceWidth = document.documentElement.clientWidth || window.innerWidth
        document.documentElement.style.fontSize = (deviceWidth / 3.75) + 'px'
    }
}

should be the code that is not exported by export in your rem.js, so when you use import, you prompt that export cannot be found


write this directly in main.js:

import './assets/js/rem.js'
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e62e8f-459f6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e62e8f-459f6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?