Updated dev webpack config.

This commit is contained in:
2020-12-06 22:56:30 +01:00
parent ce7e05fd43
commit 9265572e45
3 changed files with 16 additions and 14 deletions

View File

@@ -11,7 +11,7 @@ const webpackConfig = function(isDev) {
resolve: { resolve: {
extensions: [".js", ".vue"], extensions: [".js", ".vue"],
alias: { alias: {
vue$: isDev ? "vue/dist/vue.min.js" : "vue/dist/vue.min.js", vue$: "vue/dist/vue.min.js",
"@": helpers.root("frontend") "@": helpers.root("frontend")
} }
}, },
@@ -45,14 +45,14 @@ const webpackConfig = function(isDev) {
{ {
test: /\.css$/, test: /\.css$/,
use: [ use: [
isDev ? "vue-style-loader" : MiniCSSExtractPlugin.loader, MiniCSSExtractPlugin.loader,
{ loader: "css-loader", options: { sourceMap: isDev } } { loader: "css-loader", options: { sourceMap: isDev } }
] ]
}, },
{ {
test: /\.scss$/, test: /\.scss$/,
use: [ use: [
isDev ? "vue-style-loader" : MiniCSSExtractPlugin.loader, MiniCSSExtractPlugin.loader,
{ loader: "css-loader", options: { sourceMap: isDev } }, { loader: "css-loader", options: { sourceMap: isDev } },
{ loader: "sass-loader", options: { sourceMap: isDev } } { loader: "sass-loader", options: { sourceMap: isDev } }
] ]

View File

@@ -1,12 +1,13 @@
"use strict"; "use strict";
const webpack = require("webpack"); const webpack = require("webpack");
const merge = require("webpack-merge"); const { merge } = require("webpack-merge");
const FriendlyErrorsPlugin = require("friendly-errors-webpack-plugin"); const FriendlyErrorsPlugin = require("friendly-errors-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin"); const HtmlWebpackPlugin = require("html-webpack-plugin");
const helpers = require("./helpers"); const helpers = require("./helpers");
const commonConfig = require("./webpack.config.common"); const commonConfig = require("./webpack.config.common");
const environment = require("./env/dev.env"); const environment = require("./env/dev.env");
const MiniCSSExtractPlugin = require("mini-css-extract-plugin");
let webpackConfig = merge(commonConfig(true), { let webpackConfig = merge(commonConfig(true), {
mode: "development", mode: "development",
@@ -14,19 +15,20 @@ let webpackConfig = merge(commonConfig(true), {
output: { output: {
path: helpers.root("dist"), path: helpers.root("dist"),
publicPath: "/", publicPath: "/",
filename: "js/[name].bundle.js", filename: "js/[name].bundle.js"
chunkFilename: "js/[id].chunk.js"
}, },
optimization: { optimization: {
runtimeChunk: "single", concatenateModules: true,
splitChunks: { splitChunks: {
chunks: "all" chunks: "initial"
} }
}, },
plugins: [ plugins: [
new webpack.EnvironmentPlugin(environment), new webpack.EnvironmentPlugin(environment),
new webpack.HotModuleReplacementPlugin(), new FriendlyErrorsPlugin(),
new FriendlyErrorsPlugin() new MiniCSSExtractPlugin({
filename: "css/[name].css"
})
], ],
devServer: { devServer: {
compress: true, compress: true,
@@ -42,7 +44,7 @@ let webpackConfig = merge(commonConfig(true), {
webpackConfig = merge(webpackConfig, { webpackConfig = merge(webpackConfig, {
plugins: [ plugins: [
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: "src/templates/Index.html" template: "frontend/templates/Index.html"
}) })
] ]
}); });

View File

@@ -1,11 +1,11 @@
const VinlottisPage = () => import( const VinlottisPage = () => import(
/* webpackChunkName: "lading-page" */ /* webpackChunkName: "landing-page" */
"@/components/VinlottisPage"); "@/components/VinlottisPage");
const LotteryPage = () => import( const LotteryPage = () => import(
/* webpackChunkName: "lading-page" */ /* webpackChunkName: "landing-page" */
"@/components/LotteryPage"); "@/components/LotteryPage");
const GeneratePage = () => import( const GeneratePage = () => import(
/* webpackChunkName: "lading-page" */ /* webpackChunkName: "landing-page" */
"@/components/GeneratePage"); "@/components/GeneratePage");
const TodaysPage = () => import( const TodaysPage = () => import(