Почему я получаю следующее предупреждение "ПРЕДУПРЕЖДЕНИЕ в имени файла. js содержит недопустимую исходную карту при запуске производственной сборки моего приложения? - PullRequest
0 голосов
/ 14 марта 2020

Я пытаюсь создать свое приложение Vue и всякий раз, когда я пытаюсь запустить сборку. Я получаю предупреждение, и файл карты не создается. Это мой веб-пакет и пакет. json конфигурация. Если я удалил параметры UglifyJsPlugin из моего веб-пакета. Все работает без ошибок. Однако мне сказали, что это хорошая идея - увеличить мой javascript для производства.


  "name": "vue-mvc",
  "version": "1.0.0",
  "sideEffects": false,
  "scripts": {
    "dev": "cross-env NODE_ENV=dev WATCH=true webpack --env.watch=true --progress --hide-modules --mode development",
    "build": "cross-env NODE_ENV=production webpack --progress --hide-modules --mode production",

  },
  "dependencies": {
    "vue": "^2.6.11",
    "vue-cookies": "^1.7.0"
  },
  "devDependencies": {
    "babel-loader": "^8.0.6",
    "@babel/core": "7.8.7",
    "axios": "^0.19.2",
    "cross-env": "^7.0.2",
    "vue-style-loader": "4.1.2",
    "css-loader": "^3.4.2",
    "file-loader": "^5.1.0",
    "fs": "^0.0.2",
    "node-sass": "^4.5.3",
    "sass-loader": "^8.0.2",
    "style-loader": "^1.1.3",
    "uglifyjs-webpack-plugin": "^2.2.0",
    "uglify-js": "3.8.0",
    "vue-loader": "^15.9.0",
    "vue-template-compiler": "^2.6.11",
    "webpack": "^4.42.0",
    "webpack-cli": "^3.3.11"
  }
}
 var path = require('path');
    var webpack = require('webpack');
    var fs = require('fs');

    var appBasePath = './Scripts/'; 
    var publicPath = '../bundle/'; 
    var bundleExportPath = './wwwroot/bundle/'; // directory to export build files

    var jsEntries = {}; // listing to compile

    // We search for js files inside basePath folder and make those as entries
    fs.readdirSync(appBasePath).forEach(function (name) {

    // assumption: modules are located in separate directory and each module component is imported to 
    index.js of particular module
    var indexFile = appBasePath + name + '/index.js'
    if (fs.existsSync(indexFile)) {
        jsEntries[name] = indexFile
    }
     });

     const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
     const VueLoaderPlugin = require('vue-loader/lib/plugin')
     const TerserPlugin = require('terser-webpack-plugin');

     module.exports = {
       entry: jsEntries,
       output: {
        path: path.resolve(__dirname, bundleExportPath),
        publicPath: publicPath,
        filename: '[name].js',
        sourceMapFilename: "[name].js.map"
    },
    resolve: {
        extensions: ['.js', '.vue', '.json'],
        alias: {
            'vue$': 'vue/dist/vue.esm.js',
            '@': path.join(__dirname, appBasePath)
        }
    },
    module: {
        rules: [
            {
                test: /\.vue$/,
                loader: 'vue-loader',
                options: {
                    loaders: {
                        scss: 'vue-style-loader!css-loader!sass-loader', // <style lang="scss">
                        sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax' // <style 
          lang="sass">
                    }
                }
            },

            {
               Add Exclude https://vue-loader.vuejs.org/migrating.html#loader-inference
                test: /\.js$/,
                loader: 'babel-loader',
                exclude: file => (
                    /node_modules/.test(file) &&
                    !/\.vue\.js/.test(file)
                )
            },

            {

                test: /\.css$/,
                use: [
                    'vue-style-loader',
                    'css-loader'
                ]
            },
            {
                test: /\.scss$/,
                loader: 'style-loader!css-loader!sass-loader'
            },
            {
                test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,
                loader: 'file-loader'
            },
            {
                test: /\.(png|jpe?g|gif|svg)(\?\S*)?$/,
                loader: 'file-loader',
                query: {
                    name: '[name].[ext]?[hash]'
                }
            }
        ]
    },
    plugins: [

        new VueLoaderPlugin()

    ],
     devtool: 'source-map', //'#eval-source-map'
     }
     module.exports.watch = process.env.WATCH === "true";
     if (process.env.NODE_ENV === 'production') {
     module.exports.devtool = 'source-map'
     // http://vue-loader.vuejs.org/en/workflow/production.html
     module.exports.plugins = (module.exports.plugins || []).concat([
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: '"production"'
            }
        }),
        new UglifyJsPlugin({
            "uglifyOptions":
            {
                warnings: false,
                sourceMap: true
            }
        })
    ]);
    }
    else if (process.env.NODE_ENV === "dev") {
    module.exports.watch = true;
    module.exports.plugins = (module.exports.plugins || []).concat([
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: '"development"'
            }
        }),
      ]);
    }

...