Created
May 18, 2023 17:16
-
-
Save Danushka181/ded6d7a9a1a18a805fbfd90b465f1af6 to your computer and use it in GitHub Desktop.
This is for compile js and css using webpack to a one file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const miniCss = require("mini-css-extract-plugin"); | |
| const browserSyncPlugin = require("browser-sync-webpack-plugin"); | |
| module.exports = { | |
| mode: "production", | |
| entry: { | |
| main: ["./assets/js/index.js", "./assets/scss/styles.scss"], | |
| }, | |
| output: { | |
| path: __dirname + "/dist/js/", | |
| filename: "[name].min.js", | |
| }, | |
| watch: true, | |
| module: { | |
| rules: [ | |
| { | |
| test: /\.(s*)css$/, | |
| use: [ | |
| { | |
| loader: miniCss.loader, | |
| options: { | |
| publicPath: "", | |
| }, | |
| }, | |
| "css-loader", | |
| "sass-loader", | |
| ], | |
| }, | |
| { | |
| test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/, | |
| use: [ | |
| { | |
| loader: "file-loader", | |
| options: { | |
| name: "[name].[ext]", | |
| outputPath: "../fonts/", | |
| }, | |
| }, | |
| ], | |
| }, | |
| ], | |
| }, | |
| plugins: [ | |
| new miniCss({ | |
| filename: "../css/[name].min.css", | |
| }), | |
| new browserSyncPlugin({ | |
| host: "localhost", | |
| port: 3000, | |
| files: ["*.html"], // => files to watch | |
| // server: { | |
| // baseDir: [__dirname], | |
| // }, | |
| proxy: "http://uat-intranet.combank.net/", | |
| }), | |
| ], | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment