vue/cli4.2.3 运行vue-cli-service serve 相关loader报错?
报错“* -!../../../node_modules/css-loader/dist/cjs.js??ref--8-oneOf-3-1!../../../node_modules/postcss-loader/src/index.js??ref--8-oneOf-3-2!../../../node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-3-3!./normalize.css in ./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-3-1!./node_modules/postcss-loader/src??ref--8-oneOf-3-2!./node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-3-3!./client/common/styles/index.scss
”
vue-config.js 配置如下:
module.exports = {
devServer: devServer,
// 输出文件目录
assetsDir: "static",
// 修改 pages 入口
pages: {
index: {
entry: 'client/main.js', // 入口
template: 'public/engine-h5.html', // 模板
filename: 'index.html' // 输出文件
}
},
css: {
loaderOptions: {
sass: {
prependData: `
@import "@/common/styles/variables.scss";
`
},
scss: {
prependData: `
@import "@/common/styles/variables.scss";
`
}
}
},
productionSourceMap: process.env.NODE_ENV !== 'production',
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
// 生产环境
config.plugins.push(
new CompressionWebpackPlugin({
filename: '[path].gz[query]', // 提示示compression-webpack-plugin@3.0.0的话asset改为filename
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
})
);
} else {
// 开发环境
}
},
// 扩展 webpack 配置
chainWebpack: config => {
// @ 默认指向 src 目录,这里要改成 examples
// 另外也可以新增一个 ~ 指向 packages
config.resolve.alias
.set('@', path.resolve('client'))
.set('@client', path.resolve('client'))
.set('@server', path.resolve('server'))
.end()
config.module
.rule('js')
.include.add(/engine-template/).end()
.include.add(/client/).end()
.use('babel')
.loader('babel-loader')
.tap(options => {
// 修改它的选项...
return options
})
}
}
package.json 配置如下:
"dependencies": {
"animate.css": "^3.7.2",
"axios": "^0.19.0",
"core-js": "^3.6.4",
"crypto-js": "^3.1.9-1",
"dom-to-image": "^2.6.0",
"element-ui": "^2.4.9",
"font-awesome": "^4.7.0",
"iscroll": "^5.2.0",
"koa-body": "^4.1.1",
"koa-ejs": "^4.2.0",
"lodash": "^4.17.15",
"mongodb": "^3.5.5",
"mongoose": "^5.9.5",
"normalize.css": "7.0.0",
"nprogress": "^0.2.0",
"qrcode.vue": "^1.6.3",
"swiper": "^4.5.0",
"vue": "^2.6.11",
"vue-clipboard2": "^0.3.1",
"vue-cropper": "^0.4.9",
"vue-router": "^3.1.5",
"vuex": "^3.1.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.2.0",
"@vue/cli-plugin-router": "~4.2.0",
"@vue/cli-plugin-vuex": "~4.2.0",
"@vue/cli-service": "~4.2.0",
"art-template": "^4.13.2",
"co": "^4.6.0",
"compression-webpack-plugin": "^3.0.0",
"debug": "^4.1.1",
"html2canvas": "^1.0.0-rc.5",
"html2canvas-proxy": "^1.0.1",
"jsonwebtoken": "^8.5.1",
"koa": "^2.10.0",
"koa-art-template": "^1.1.1",
"koa-bodyparser": "^4.2.1",
"koa-convert": "^1.2.0",
"koa-json": "^2.0.2",
"koa-jwt": "^3.6.0",
"koa-logger": "^3.2.1",
"koa-onerror": "^4.1.0",
"koa-router": "^7.4.0",
"koa-static": "^5.0.0",
"koa-views": "^6.2.1",
"koa2-cors": "^2.0.6",
"node-sass": "^4.12.0",
"nodemon": "^1.19.4",
"pug": "^2.0.3",
"sass-loader": "^8.0.2",
"vue-template-compiler": "^2.6.11",
"babel-eslint": "^10.0.3",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.1.2"
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论