diff --git a/package.json b/package.json index 50a75de..4260aa0 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "webpack.config.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build": "webpack", + "build-dev": "webpack --config-name dev-cfg", + "build-public": "webpack --config-name prod-cfg", "clean-dev": "rm ./dev/ -r", "clean-public": "rm ./public/ -r", "server": "webpack server" diff --git a/webpack.config.js b/webpack.config.js index 8e31ad1..272a2e6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,7 +1,6 @@ const path = require('path'); const MediaQueryPlugin = require('media-query-plugin'); const HtmlWebpackPlugin = require("html-webpack-plugin"); -const {CleanWebpackPlugin} = require("clean-webpack-plugin"); const CopyWebpackPlugin = require("copy-webpack-plugin"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const CssMinimizerPlugin = require("css-minimizer-webpack-plugin"); @@ -12,9 +11,11 @@ module.exports = { entry: "./src/script/tailwind.config.js", mode: "production", + name: "prod-cfg", output: { filename: "script/tailwind.config.js", path: path.resolve(__dirname, "public"), + clean:true, }, module: { rules: [ @@ -38,6 +39,13 @@ module.exports = name: "/pic/[name].[ext]", } }, + { + test: /\.(eot|svg|ttf|woff|woff2|otf)$/, + type: "asset/resource", + generator: { + filename: "fonts/[hash][ext][query]" + } + }, ] }, optimization: { @@ -48,7 +56,6 @@ module.exports = minimize: true, }, plugins:[ - new CleanWebpackPlugin(), new HtmlWebpackPlugin({ filename: "index.html", template: "./src/index.html", @@ -64,14 +71,16 @@ module.exports = "screen and (min-width: 900px)": "desktop" } }), - ], + ] }, { entry: "./src/script/tailwind.config.js", mode: "development", + name: "dev-cfg", output: { filename: "script/tailwind.config.js", path: path.resolve(__dirname, "dev"), + clean:true, }, module: { rules: [ @@ -90,32 +99,21 @@ module.exports = name: "/pic/[name].[ext]", } }, - ] + ]}, + plugins:[ + new HtmlWebpackPlugin({ + filename: "index.html", + template: "./src/index.html", + }), + ], + devServer: + { + static: { + directory: path.join(__dirname, 'dev'), + }, + compress: false, + open: "/", + port: 8080, + } }, - plugins:[ - new CleanWebpackPlugin(), - /* - new CopyWebpackPlugin({ - patterns: [ - {from: "./src/pic/", to: "./pic"}, - {from: "./src/css/", to: "./css"}, - {from: "./src/fonts/", to: "./fonts"}, - ] - - }),*/ - new HtmlWebpackPlugin({ - filename: "index.html", - template: "./src/index.html", - }), - ], - devServer: - { - static: { - directory: path.join(__dirname, 'dev'), - }, - compress: false, - open: "/", - port: 8080, - } - }, ]