From 608881d228bbc344dbabfec2da316f5038108999 Mon Sep 17 00:00:00 2001 From: Veronika Date: Fri, 6 Sep 2024 17:01:07 +0300 Subject: [PATCH] updated webpack.config to fix bug for dev --- .gitignore | 1 + webpack.config.js | 92 +++++++++++++++++++++++------------------------ 2 files changed, 46 insertions(+), 47 deletions(-) diff --git a/.gitignore b/.gitignore index a0446a5..04e1ccf 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ yarn-error.log *.ntvs* *.njsproj *.sln +.vscode/* diff --git a/webpack.config.js b/webpack.config.js index 6682ad8..1f3e0dd 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,86 +1,84 @@ -var path = require('path') -var webpack = require('webpack') -var HtmlWebpackPlugin = require('html-webpack-plugin') -const VueLoaderPlugin = require('vue-loader/lib/plugin') +var path = require("path"); +var webpack = require("webpack"); +var HtmlWebpackPlugin = require("html-webpack-plugin"); +const VueLoaderPlugin = require("vue-loader/lib/plugin"); module.exports = { - entry: './src/main.js', + entry: "./src/main.js", output: { - path: path.resolve(__dirname, './dist'), - publicPath: 'dist/', - filename: 'build.js' + path: path.resolve(__dirname, "./dist"), + publicPath: "dist/", + filename: "build.js", }, module: { rules: [ { test: /\.css$/, - use: [ - 'vue-style-loader', - 'css-loader' - ], - }, { + use: ["vue-style-loader", "css-loader"], + }, + { test: /\.vue$/, - loader: 'vue-loader', + loader: "vue-loader", options: { - loaders: { - } + loaders: {}, // other vue-loader options go here - } + }, }, { test: /\.js$/, - loader: 'babel-loader', - exclude: /node_modules/ + loader: "babel-loader", + exclude: /node_modules/, }, { test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/, - loader: 'file-loader', + loader: "file-loader", options: { - name: '[name].[ext]', - outputPath: 'fonts/' - } + name: "[name].[ext]", + outputPath: "fonts/", + }, }, { test: /\.(png|jpg|gif|svg|mp3)$/, - loader: 'file-loader', + loader: "file-loader", options: { - name: '[name].[ext]?[hash]' - } - } - ] + name: "[name].[ext]?[hash]", + }, + }, + ], }, resolve: { alias: { - 'vue$': 'vue/dist/vue.esm.js' + vue$: "vue/dist/vue.esm.js", }, - extensions: ['*', '.js', '.vue', '.json'] + extensions: ["*", ".js", ".vue", ".json"], }, devServer: { - static: { - directory: path.join(__dirname, '/') - } + static: { + directory: path.join(__dirname, "/"), + }, }, performance: { - hints: false + hints: false, }, - devtool: 'eval-source-map', + devtool: "eval-source-map", plugins: [ // make sure to include the plugin for the magic - new VueLoaderPlugin() - ] -} + new VueLoaderPlugin(), + new HtmlWebpackPlugin({ template: "./index.html" }), + ], +}; -if (process.env.NODE_ENV === 'production') { - module.exports.devtool = 'source-map' +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"' - } - }), + "process.env": { + NODE_ENV: '"production"', + }, + }), new webpack.LoaderOptionsPlugin({ - minimize: true - }), - ]) + minimize: true, + }), + ]); }