Created
September 28, 2020 02:37
-
-
Save reciosonny/eae01e0ef5ea7daf8c5f8e3670ff957c to your computer and use it in GitHub Desktop.
This file contains 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 webpack = require("webpack"); | |
const webpackMerge = require("webpack-merge"); | |
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | |
const path = require("path"); | |
const modeConfig = env => require(`./modes/webpack.${env}.js`)(env); | |
const pluginConfig = require("./loadPlugins"); | |
module.exports = ({ mode, presets } = { mode: "development", presets: [] }) => { | |
return webpackMerge( | |
{ | |
entry: { | |
bundle_kanbanboard: "./src/index.js", | |
bundle_coupons_index: "./src/Modules/Administrator/Coupons/Index/index.js", | |
bundle_purchaseorders_prepareorder: "./src/Modules/Framer/PurchaseOrders/PrepareOrder/index.js", | |
bundle_purchaseorders_add: "./src/Modules/Framer/PurchaseOrders/Add/index.js" | |
}, | |
output: { | |
path: path.resolve(__dirname, "../../Assets/Scripts/dist"), | |
filename: "[name].js", | |
chunkFilename: "[name].lazy-chunk.js", | |
publicPath: "../../Assets/Scripts/dist/" | |
}, | |
devServer: { | |
hot: true, | |
proxy: { | |
"/": { | |
target: "http://localhost/", | |
secure: false, | |
changeOrigin: true | |
} | |
}, | |
port: 3000 | |
}, | |
mode, | |
module: { | |
rules: [ | |
{ | |
use: { | |
loader: "babel-loader" | |
}, | |
test: /\.js$/, | |
exclude: /node_modules/ //excludes node_modules folder from being transpiled by babel. We do this because it's a waste of resources to do so. | |
}, | |
{ | |
use: ["style-loader", "css-loader"], | |
test: /\.css$/ | |
}, | |
{ | |
test: /\.scss$/, | |
use: [ | |
MiniCssExtractPlugin.loader, | |
"css-loader" | |
] | |
}, | |
{ test: /\.json$/, loader: 'json-loader' }, | |
] | |
}, | |
plugins: [ | |
new webpack.DefinePlugin({ | |
"process.env.NODE_ENV": JSON.stringify(mode) //we will set the correct variable for `process.env.NODE_ENV` variable inside the `scripts` property in `package.json` | |
}) //This adds windows-scoped variables that will be defined in bundle.js | |
] | |
}, | |
pluginConfig({ mode, presets }), | |
modeConfig(mode) | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment