shift73k/assets/webpack.config.js

46 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-02-24 12:02:48 -05:00
const path = require("path");
const glob = require("glob");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
2020-09-12 18:43:17 -04:00
module.exports = (env, options) => {
2021-02-24 12:02:48 -05:00
const devMode = options.mode !== "production";
2020-09-12 18:43:17 -04:00
return {
entry: {
2021-02-24 12:02:48 -05:00
app: glob.sync("./vendor/**/*.js").concat(["./js/app.js"]),
2020-09-12 18:43:17 -04:00
},
output: {
2021-02-24 12:02:48 -05:00
path: path.resolve(__dirname, "../priv/static/js"),
filename: "[name].js",
publicPath: "/js/",
2020-09-12 18:43:17 -04:00
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
2021-02-24 12:02:48 -05:00
loader: "babel-loader",
},
2020-09-12 18:43:17 -04:00
},
{
test: /\.[s]?css$/,
2021-02-24 12:02:48 -05:00
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
},
],
2020-09-12 18:43:17 -04:00
},
plugins: [
2021-02-24 12:02:48 -05:00
new MiniCssExtractPlugin({ filename: "../css/app.css" }),
new CopyWebpackPlugin({
patterns: [{ from: "static/", to: "../" }],
}),
],
optimization: {
minimizer: ["...", new CssMinimizerPlugin()],
},
devtool: devMode ? "source-map" : undefined,
};
2020-09-12 18:43:17 -04:00
};