我vue-cli-service serve
用来编译 scss 并捆绑输出
这是我里面的webpack配置vue.config.js
configureWebpack: {
entry: {
main: [`${process.cwd()}/src/main.js`],
app: [`${process.cwd()}/src/vue.js`]
},
plugins: [
new BundleTracker({ path: "../static/dist", filename: 'webpack-stats.json' }),
],
output: {
filename: '[name]-[hash].js',
}
}
这是我的package.json
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"jquery": "^3.6.0",
"openseadragon": "^2.4.2",
"vue": "^2.6.11",
"regenerator-runtime": "^0.13.7",
"vue-apollo": "^3.0.0-beta.11",
"vuex": "^3.6.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.13",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"sass": "^1.32.8",
"sass-loader": "^10.1.1",
"vue-template-compiler": "^2.6.11",
"webpack-bundle-tracker": "^0.4.3",
"@babel/core": "^7.13.16",
"@babel/eslint-parser": "^7.13.14",
"graphql-tag": "^2.9.0",
"vue-cli-plugin-apollo": "~0.22.2"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
问题
随着时间的推移,问题出现了。
起初npm run serve
没有产生正确的捆绑输出,但编译成功。例如,输出文件中没有简单的console.log
语句。npm run build
虽然编译成功。
我试图找出原因,并删除了最新的代码,并用多个console.log
语句替换它。我意识到当复制console.log('hello')
8 次时它有效,但 9 次却没有!
有几天我没问题,因为至少npm run build
运行正确,但现在在代码库增加了几个新文件之后,即使这样也不再起作用了。
我完全困惑,我不知道从哪里开始寻找错误!请帮忙!
我不是 javascript 专家,而且我对 webpack 的经验很少,这就是为什么我什至无法正确地提出问题。任何提示将不胜感激!