Skip to content

Commit 1aa4f96

Browse files
committed
Merge branch 'ujjwalguptaofficial-master'
2 parents 13b99ac + 0fdc4fd commit 1aa4f96

File tree

6 files changed

+113
-731
lines changed

6 files changed

+113
-731
lines changed

frameworks/keyed/mahal/config/webpack/base.config.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('path');
2-
const MahalPlugin = require('mahal-webpack-loader/lib/plugin');
2+
const MahalPlugin = require('@mahaljs/webpack-loader/lib/plugin');
33
const HtmlWebPackPlugin = require('html-webpack-plugin');
44
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
55
const CopyPlugin = require('copy-webpack-plugin');
@@ -19,22 +19,32 @@ module.exports = {
1919
test: /\.mahal?$/,
2020
// loader: 'mahal-webpack-loader',
2121
use: {
22-
loader: require.resolve('mahal-webpack-loader')
22+
loader: require.resolve('@mahaljs/webpack-loader')
2323
},
2424
exclude: /node_modules/
2525
},
2626
{
2727
test: /\.css?$/,
2828
use: [
29-
'style-loader',
29+
isEnvProduction ? {
30+
loader: MiniCssExtractPlugin.loader,
31+
options: {
32+
esModule: false,
33+
},
34+
} : 'style-loader',
3035
'css-loader'
3136
],
3237
},
3338
{
3439
test: /\.s[ac]ss$/i,
3540
use: [
3641
// Creates `style` nodes from JS strings
37-
'style-loader',
42+
isEnvProduction ? {
43+
loader: MiniCssExtractPlugin.loader,
44+
options: {
45+
esModule: false,
46+
},
47+
} : 'style-loader',
3848
// Translates CSS into CommonJS
3949
"css-loader",
4050
// Compiles Sass to CSS
@@ -73,8 +83,8 @@ module.exports = {
7383
},
7484
},
7585
output: {
76-
filename: isEnvProduction ? 'js/[name].js' : 'js/[name].js',
77-
chunkFilename: isEnvProduction ? 'js/[name].chunk.js' : 'js/[name].chunk.js',
86+
filename: isEnvProduction ? 'js/[name].[contenthash:8].js' : 'js/[name].js',
87+
chunkFilename: isEnvProduction ? 'js/[name].[contenthash:8].chunk.js' : 'js/[name].chunk.js',
7888
path: path.resolve(rootFolder, 'dist'),
7989
publicPath: '/'
8090
},
@@ -83,8 +93,8 @@ module.exports = {
8393
lang: 'ts'
8494
}),
8595
new HtmlWebPackPlugin({
86-
// cache: true,
87-
// hash: true,
96+
cache: true,
97+
hash: true,
8898
template: 'src/index.html',
8999
minify: {
90100
collapseWhitespace: true,
@@ -95,15 +105,9 @@ module.exports = {
95105
}
96106
}),
97107
new CleanWebpackPlugin(),
98-
new CopyPlugin({
99-
patterns: [{
100-
from: './assets/',
101-
to: ''
102-
}]
103-
}),
104-
// new MiniCssExtractPlugin({
105-
// filename: 'css/[name].css',
106-
// chunkFilename: 'css/[name].chunk.css',
107-
// })
108+
new MiniCssExtractPlugin({
109+
filename: isEnvProduction ? 'css/[name].[contenthash:8].css' : 'css/[name].css',
110+
chunkFilename: isEnvProduction ? 'css/[name].[contenthash:8].chunk.css' : 'css/[name].chunk.css',
111+
})
108112
]
109113
};

frameworks/keyed/mahal/config/webpack/dev.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ const baseConfig = require('./base.config');
55
module.exports = merge(baseConfig, {
66
devServer: {
77
historyApiFallback: true,
8+
static: {
9+
directory: path.join(__dirname, '../../assets'),
10+
},
811
},
912
});

frameworks/keyed/mahal/config/webpack/prod.config.js

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,53 @@
11
const { merge } = require('webpack-merge')
22
const baseConfig = require('./base.config')
3+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
4+
const CopyPlugin = require('copy-webpack-plugin');
35

46
const prod = merge(baseConfig, {
5-
mode: 'production',
7+
mode: process.env.NODE_ENV || 'development',
68
devtool: false,
79
output: {
8-
publicPath: 'dist/',
10+
publicPath: '/frameworks/keyed/mahal/dist/',
11+
filename: 'js/[name].[contenthash].bundle.js',
12+
},
13+
optimization: {
14+
minimize: true,
15+
minimizer: [`...`, new CssMinimizerPlugin()],
16+
runtimeChunk: {
17+
name: 'runtime',
18+
},
19+
splitChunks: {
20+
chunks: 'all',
21+
maxInitialRequests: Infinity,
22+
minSize: 100000,
23+
maxSize: 1000000,
24+
cacheGroups: {
25+
vendor: {
26+
test: /[\\/]node_modules[\\/]/,
27+
name(module) {
28+
// get the name. E.g. node_modules/packageName/not/this/part.js
29+
// or node_modules/packageName
30+
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
31+
// console.log('package', packageName);
32+
// npm package names are URL-safe, but some servers don't like @ symbols
33+
return `npm.${packageName.replace('@', '')}`;
34+
},
35+
},
36+
},
37+
},
38+
},
39+
plugins: [
40+
new CopyPlugin({
41+
patterns: [{
42+
from: './assets/',
43+
to: ''
44+
}]
45+
})
46+
],
47+
performance: {
48+
hints: false,
49+
maxEntrypointSize: 512000,
50+
maxAssetSize: 512000,
951
},
1052
})
1153

frameworks/keyed/mahal/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Mahal</title><link href="/css/currentStyle.css" rel="stylesheet"><script defer="defer" src="dist/js/main.js"></script></head><body><span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span><div id="main"></div></body></html>
1+
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Mahal</title><link href="/css/currentStyle.css" rel="stylesheet"><script defer="defer" src="/frameworks/keyed/mahal/dist/js/runtime.8bf36938d9012d6ced34.bundle.js?b83370a6094779c319a5"></script><script defer="defer" src="/frameworks/keyed/mahal/dist/js/main.b7078a368dbf8712eb94.bundle.js?b83370a6094779c319a5"></script><link href="/frameworks/keyed/mahal/dist/css/main.31d6cfe0.css?b83370a6094779c319a5" rel="stylesheet"></head><body><span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span><div id="main"></div></body></html>

0 commit comments

Comments
 (0)