gpt4 book ai didi

javascript - laravel vue 控制台中的缩进问题

转载 作者:行者123 更新时间:2023-12-02 23:17:16 25 4
gpt4 key购买 nike

我在 Laravel 中使用 Vue。面临控制台中分配缩进错误的问题。

enter image description here

我的 package.json 文件

"private": true,
"scripts": {
"clean": "rimraf public/build",
"build": "npm run clean && webpack --mode development --progress",
"watch": "npm run clean && npm run build -- --watch",
"dev": "npm run clean && webpack-dev-server --mode development --hot --progress",
"prod": "rimraf public/dist && cross-env NODE_ENV=production webpack --mode production --progress",
"lint": "eslint --ext .js,.vue resources/js"
},

如何消除所有 pretter/pretter 错误?并成功构建,没有任何问题。请指导或帮助。

我还应该在生产中运行哪个命令才能使一切正常运行?

npm run watch 开发错误截图如下。npm run prod 在生产中面临的问题

我是 vue 新手,所以对此不太了解。

require('dotenv').config()
const path = require('path')
const webpack = require('webpack')

const { VueLoaderPlugin } = require('vue-loader')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin')
const WebpackNotifierPlugin = require('webpack-notifier')
const ManifestPlugin = require('webpack-manifest-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin

const hmr = process.argv.includes('--hot')
const production = process.env.NODE_ENV === 'production'
const devServerPort = parseInt(process.env.DEV_SERVER_PORT || '8080', 10)
const devServerUrl = process.env.DEV_SERVER_URL || 'http://localhost:8080'

const publicPathFolder = production ? '/dist/' : '/build/'
const publicPath = hmr ? `${devServerUrl}${publicPathFolder}` : publicPathFolder

function getEntryConfig (name, analyzerPort, alias = {}) {
let plugins = [
new VueLoaderPlugin(),
new webpack.IgnorePlugin(/jsdom$/),
new FriendlyErrorsWebpackPlugin(),
new WebpackNotifierPlugin(),
new MiniCssExtractPlugin({
filename: production ? 'css/[name].[chunkhash].css' : 'css/[name].css'
}),
new ManifestPlugin({
fileName: `manifest-${name}.json`,
publicPath,
writeToFileEmit: true
})
]

if (production) {
plugins.push(...[
new BundleAnalyzerPlugin({
analyzerPort
})
])
}

let postcssPlugins = [
require('autoprefixer')()
]

if (production) {
postcssPlugins.push(require('cssnano')())
}

let cssLoaders = [
hmr ? 'vue-style-loader' : MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
sourceMap: true
}
}, {
loader: 'postcss-loader',
options: {
ident: 'postcss',
sourceMap: true,
plugins: postcssPlugins
}
}
]

return {
entry: {
[name]: [
`./resources/js/${name}/app.js`,
`./resources/sass/${name}/app.scss`
]
},
output: {
path: path.resolve(__dirname, 'public' + publicPathFolder),
filename: production ? 'js/[name].[chunkhash].js' : 'js/[name].js',
publicPath
},
module: {



rules: [
{
test: /\.css$/,
use: cssLoaders
},
{
test: /\.scss$/,
use: cssLoaders.concat([
{
loader: 'resolve-url-loader'
}, {
loader: 'sass-loader',
options: {
outputStyle: 'expanded',
sourceMap: true
}
}
])
},
{
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre'
},
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
},
{
test: /\.(png|jpe?g|gif)$/,
use: [
{
loader: 'url-loader',
options: {
name: (path) => {
if (!/node_modules/.test(path)) {
return 'images/[name].[ext]?[hash]'
}

return `images/vendor-${name}/` + path
.replace(/\\/g, '/')
.replace(
/((.*(node_modules))|images|image|img|assets)\//g, ''
) + '?[hash]'
},
limit: 4096
}
}
]
},
{
test: /\.(woff2?|ttf|eot|svg|otf)$/,
loader: 'url-loader',
options: {
name: (path) => {
if (!/node_modules/.test(path)) {
return 'fonts/[name].[ext]?[hash]'
}

return `fonts/vendor-${name}/[name].[ext]?[hash]`
},
limit: 4096
}
}
]
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /node_modules.*\.js$/,
name: `vendor-${name}`,
chunks: 'all'
}
}
}
},
plugins,
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: Object.assign({
'sweetalert2$': 'sweetalert2/dist/sweetalert2.js'
}, alias)
},
externals: {
jquery: 'jQuery',
'popper.js': 'Popper'
},
devtool: production ? 'source-map' : 'cheap-module-eval-source-map',
devServer: {
contentBase: path.resolve(__dirname, 'public'),
headers: {
'Access-Control-Allow-Origin': '*'
},
historyApiFallback: true,
compress: true,
noInfo: true,
quiet: true,
port: devServerPort
}
}
}

module.exports = [

getEntryConfig('frontend', 8888, {
'vue$': 'vue/dist/vue.esm.js'

}),



getEntryConfig('backend', 8889),



];

最佳答案

要禁用 linting,请更新您的 `` 以删除 eslint 加载器(这是产生错误的加载器)。

请注意,您的代码将不再被检查,并且可能包含语法错误等。检查通常是一个很好的做法,因此如果可能的话,您应该修复错误。

删除这些行:

{
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre'
},

关于javascript - laravel vue 控制台中的缩进问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57117774/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com