问题1. Can't resolve './cptable' in 'xxx\node_modules_xlsx
在vue.config.js中引入以下代码
configureWebpack: {
externals: {
'./cptable': 'var cptable'
},
},
问题2. Can't resolve 'fs'
在vue.config.js中引入以下代码
module.exports = defineConfig({
transpileDependencies: true,
configureWebpack: {
externals: {
'./cptable': 'var cptable'
},
resolve: {
fallback: {
fs: false
}
},
}
})
问题3:Can't resolve 'crypto'in D: code-a\LPA2 admin node modules (xlsx-style)
在vue.config.js中引入以下代码
module.exports = defineConfig({
transpileDependencies: true,
configureWebpack: {
externals: {
'./cptable': 'var cptable'
},
resolve: {
fallback: {
fs: false,
crypto: false,
}
},
}
})
问题4. jszip not a constructor
通过命令安装Webpack 插件
npm i node-polyfill-webpack-plugin -D
在vue.config.js中引入以下代码
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")
module.exports = defineConfig({
configureWebpack: {
plugins: [
new NodePolyfillPlugin()
]
}
})
处理完后vue.config.js整体代码如下
const { defineConfig } = require("@vue/cli-service");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")
module.exports = defineConfig({
transpileDependencies: true,
lintOnSave: false,
devServer: {
port: 8080,
host: '0.0.0.0',
client: {
webSocketURL: 'ws://0.0.0.0:8080/ws',
},
headers: {
'Access-Control-Allow-Origin': '*',
},
proxy: {
'/':{
ws: false,
target:"http://127.0.0.1:3000",
pathRewrite:{
"^/":"/"
}
}
}
},
configureWebpack: {
plugins: [
new NodePolyfillPlugin()
],
externals: {
'./cptable': 'var cptable'
},
resolve: {
fallback: {
fs: false,
crypto: false,
}
},
}
});