Skip to content

Commit

Permalink
update webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Oct 5, 2023
1 parent a369b5c commit 5e4e62a
Show file tree
Hide file tree
Showing 3 changed files with 1,291 additions and 1,288 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
38 changes: 28 additions & 10 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
const config = require("./src/config");

const path = require("path");
const glob = require('glob')
const Webpack = require("webpack");
const AssetsWebpackPlugin = require('assets-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const FixStyleOnlyEntriesPlugin = require("webpack-fix-style-only-entries");

const config = {
isProd: process.env.NODE_ENV === "production",
hmrEnabled: process.env.NODE_ENV !== "production" && !process.env.NO_HMR,
distFolder: path.resolve(__dirname, "./dist/css"),
wdsPort: 3001,
};

var webpackConfig = {
entry: {
Expand All @@ -12,10 +21,16 @@ var webpackConfig = {
output: {
path: config.distFolder,
filename: '[name].js',
publicPath: config.publicPath,
clean: true
},
mode: config.isProd ? "production" : "development",
resolve: {
alias: {
'decanter-assets': path.resolve('node_modules', 'decanter/core/src/img'),
'decanter-src': path.resolve('node_modules', 'decanter/core/src'),
'@fortawesome': path.resolve('node_modules', '@fortawesome'),
'fa-fonts': path.resolve('node_modules', '@fortawesome/fontawesome-free/webfonts')
}
},
module: {
rules: [
{
Expand All @@ -32,15 +47,19 @@ var webpackConfig = {
test: /\.(sa|sc|c)ss$/,
use: [
config.isProd ? { loader: MiniCssExtractPlugin.loader } : 'style-loader',
'css-loader',
'postcss-loader',
'sass-loader'
],
{loader:'css-loader', options: {}},
{loader:'postcss-loader', options: {}},
{loader:'sass-loader', options: {}}
]
},
{
test: /\.(png|jpg|gif|svg)$/i,
type: "asset/resource"
}
]
},
plugins: [
new AssetsWebpackPlugin({path: config.distFolder}),
new FixStyleOnlyEntriesPlugin(),
new MiniCssExtractPlugin({
filename: '[name].css',
}),
Expand All @@ -50,7 +69,6 @@ var webpackConfig = {
new OptimizeCSSAssetsPlugin(),
]
}

};

if (config.hmrEnabled) {
Expand Down
Loading

0 comments on commit 5e4e62a

Please sign in to comment.