Skip to content

Commit c6f90fb

Browse files
committed
^ fix : wp deps no more needed on head layers
1 parent ce8a8d4 commit c6f90fb

6 files changed

Lines changed: 131 additions & 133 deletions

File tree

etc/wp/webpack.config.api.js

Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -16,105 +16,105 @@ const lpackCfg = lPack.getConfig(),
1616
isExcluded = lPack.isFileExcluded();
1717

1818
module.exports = [
19-
{
20-
mode : lpackCfg.vars.production ? "production" : "development",
21-
entry : {
22-
App: [
23-
lpackCfg.vars.rootAlias + '/index.server'
24-
] // default to 'App'
25-
},
26-
target : 'async-node',
27-
output : {
28-
path : lPack.getHeadRoot() + "/" + ( lpackCfg.vars.targetDir || 'dist' ),
29-
filename : "[name].server.js",
30-
publicPath : "/",
31-
libraryTarget: "commonjs2"
32-
},
33-
devtool: 'source-map',
34-
35-
resolve: {
36-
symlinks : false,
37-
extensions: [
38-
".",
39-
".api.js",
40-
".api.jsx",
41-
".js",
42-
".jsx",
43-
".json",
44-
".scss",
45-
".css",
46-
],
47-
},
48-
49-
module : {
50-
rules: [
51-
{
52-
test : /\.jsx?$/,
53-
exclude: isExcluded,
54-
use : [
55-
{
56-
loader : 'babel-loader',
57-
options: {
58-
cacheDirectory: true, //important for performance
59-
presets : [
60-
['@babel/preset-env',
61-
{
62-
...(lpackCfg.vars.babelPreset || {})
63-
}],
64-
'@babel/preset-react'
65-
],
66-
plugins : [
67-
["@babel/plugin-proposal-decorators", { "legacy": true }],
68-
['@babel/plugin-transform-class-properties', {
69-
//"loose": true
70-
}],
71-
["@babel/plugin-transform-runtime", {}],
72-
]
73-
}
74-
},
75-
]
76-
},
77-
{
78-
test: /\.(png|jpg|gif|svg|woff2|ttf|eot)(\?.*$|$)$/,
79-
use : 'file-loader?limit=8192&name=assets/[hash].[ext]'
80-
},
81-
{
82-
test: /\.woff2?(\?.*$|$)$/,
83-
use : "url-loader?prefix=font/&limit=5000&mimetype=application/font-woff&name=assets/[hash].[ext]"
84-
},
85-
{ test: /\.html$/, use: "file-loader?name=[name].[ext]" },
86-
{ test: /\.tpl$/, use: "dot-tpl-loader?append=true" },
87-
{
88-
test : /\.(scss|css|less)(\?.*$|$)$/,
89-
use: 'null-loader'
90-
},
91-
92-
{ test: /\.otf(\?.*$|$)$/, use: "file-loader?name=assets/[hash].[ext]" },
93-
{
94-
test : /\.json?$/,
95-
use: 'strip-json-comments-loader'
96-
}
97-
],
98-
},
99-
plugins:
100-
[
101-
lPack.plugin(),
102-
103-
//new HardSourceWebpackPlugin(),
104-
...( fs.existsSync("./LICENCE.HEAD.MD") && [
105-
new webpack.BannerPlugin(fs.readFileSync("./LICENCE.HEAD.MD").toString())
106-
] || []
107-
),
108-
109-
...( lpackCfg.vars.production && [
110-
new BundleAnalyzerPlugin({
111-
analyzerMode : 'static',
112-
reportFilename: './' + lpackCfg.vars.rootAlias + '.stats.html',
113-
openAnalyzer : false,
114-
...lpackCfg.vars.BundleAnalyzerPlugin
115-
})
116-
117-
] || [] )
118-
],
119-
}
19+
{
20+
mode : lpackCfg.vars.production ? "production" : "development",
21+
entry : {
22+
App: [
23+
lpackCfg.vars.rootAlias + '/index.server'
24+
] // default to 'App'
25+
},
26+
target : 'async-node',
27+
output : {
28+
path : lPack.getHeadRoot() + "/" + (lpackCfg.vars.targetDir || 'dist'),
29+
filename : "[name].server.js",
30+
publicPath : "/",
31+
libraryTarget: "commonjs2"
32+
},
33+
devtool: 'source-map',
34+
35+
resolve: {
36+
symlinks : false,
37+
extensions: [
38+
".",
39+
".api.js",
40+
".api.jsx",
41+
".js",
42+
".jsx",
43+
".json",
44+
".scss",
45+
".css",
46+
],
47+
},
48+
49+
module : {
50+
rules: [
51+
{
52+
test : /\.jsx?$/,
53+
exclude: isExcluded,
54+
use : [
55+
{
56+
loader : 'babel-loader',
57+
options: {
58+
cacheDirectory: true, //important for performance
59+
presets : [
60+
['@babel/preset-env',
61+
{
62+
...(lpackCfg.vars.babelPreset || {})
63+
}],
64+
'@babel/preset-react'
65+
],
66+
plugins : [
67+
["@babel/plugin-proposal-decorators", { "legacy": true }],
68+
['@babel/plugin-transform-class-properties', {
69+
//"loose": true
70+
}],
71+
["@babel/plugin-transform-runtime", {}],
72+
]
73+
}
74+
},
75+
]
76+
},
77+
{
78+
test: /\.(png|jpg|gif|svg|woff2|ttf|eot)(\?.*$|$)$/,
79+
use : 'file-loader?limit=8192&name=assets/[hash].[ext]'
80+
},
81+
{
82+
test: /\.woff2?(\?.*$|$)$/,
83+
use : "url-loader?prefix=font/&limit=5000&mimetype=application/font-woff&name=assets/[hash].[ext]"
84+
},
85+
{ test: /\.html$/, use: "file-loader?name=[name].[ext]" },
86+
{ test: /\.tpl$/, use: "dot-tpl-loader?append=true" },
87+
{
88+
test: /\.(scss|css|less)(\?.*$|$)$/,
89+
use : 'null-loader'
90+
},
91+
92+
{ test: /\.otf(\?.*$|$)$/, use: "file-loader?name=assets/[hash].[ext]" },
93+
{
94+
test: /\.json?$/,
95+
use : 'strip-json-comments-loader'
96+
}
97+
],
98+
},
99+
plugins:
100+
[
101+
lPack.plugin(),
102+
103+
//new HardSourceWebpackPlugin(),
104+
...(fs.existsSync("./LICENCE.HEAD.MD") && [
105+
new webpack.BannerPlugin(fs.readFileSync("./LICENCE.HEAD.MD").toString())
106+
] || []
107+
),
108+
109+
...(lpackCfg.vars.production && [
110+
new BundleAnalyzerPlugin({
111+
analyzerMode : 'static',
112+
reportFilename: './' + lpackCfg.vars.rootAlias + '.stats.html',
113+
openAnalyzer : false,
114+
...lpackCfg.vars.BundleAnalyzerPlugin
115+
})
116+
117+
] || [])
118+
],
119+
}
120120
]

etc/wp/webpack.config.comp.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const lPack = require('layer-pack'),
1212
path = require("path"),
1313
HtmlWebpackPlugin = require('html-webpack-plugin'),
1414
BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin,
15-
HardSourceWebpackPlugin = require('hard-source-webpack-plugin'),
1615
autoprefixer = require('autoprefixer'),
1716
ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
1817

etc/wp/webpack.config.www.js

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ const TerserJSPlugin = require('terser-webpack-plugin'),
1212
path = require("path"),
1313
HtmlWebpackPlugin = require('html-webpack-plugin'),
1414
BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin,
15-
autoprefixer = require('autoprefixer'),
16-
MiniCssExtractPlugin = require('mini-css-extract-plugin'),
17-
HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
15+
MiniCssExtractPlugin = require('mini-css-extract-plugin');
1816
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
1917
const lpackCfg = lPack.getConfig(),
2018
isExcluded = lPack.isFileExcluded(),
@@ -119,13 +117,13 @@ module.exports = [
119117

120118
cache: {
121119
type : "filesystem",
122-
allowCollectingMemory: true,
120+
//allowCollectingMemory: true,
123121
//cacheDirectory : lPack.getHeadRoot() + "/" + (lpackCfg.vars.targetDir || 'dist') + "/cache",
124122
},
125123

126124
// required files resolving options
127125
resolve: {
128-
cache : false,// requiered for module cache to create indexes
126+
//cache : false,// requiered for module cache to create indexes
129127
mainFields: ['browser', 'main', 'module'],
130128
extensions: [
131129
".",
@@ -225,31 +223,31 @@ module.exports = [
225223
use : [
226224
"style-loader",
227225
{ loader: 'css-loader', options: { importLoaders: 1 } },
228-
{
229-
loader : 'postcss-loader',
230-
options: {
231-
postcssOptions: {
232-
plugins: [
233-
[
234-
autoprefixer({
235-
overrideBrowserslist: [
236-
'>1%',
237-
'last 4 versions',
238-
'Firefox ESR',
239-
'not ie < 9', // React doesn't support IE8 anyway
240-
]
241-
}),
242-
]]
243-
244-
}
245-
}
246-
},
226+
//{
227+
// loader : 'postcss-loader',
228+
// options: {
229+
// postcssOptions: {
230+
// plugins: [
231+
// [
232+
// autoprefixer({
233+
// overrideBrowserslist: [
234+
// '>1%',
235+
// 'last 4 versions',
236+
// 'Firefox ESR',
237+
// 'not ie < 9', // React doesn't support IE8 anyway
238+
// ]
239+
// }),
240+
// ]]
241+
//
242+
// }
243+
// }
244+
//},
247245
{
248246
loader : "sass-loader",
249247
options: {
250248
sassOptions: {
251249
importer : lPack.plugin().sassImporter(),
252-
sourceMaps: true
250+
sourceMaps: !!lpackCfg.vars.production
253251
},
254252
}
255253
}

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lpack-react",
3-
"version": "2.1.1",
3+
"version": "2.1.2",
44
"description": "An inheritable App, lib or static App boilerplate with wp5, react, sass, hmr, SSR, express, helmet, etc",
55
"license": "MIT",
66
"author": "Nathan Braun <n8tz.js@gmail.com>",
@@ -39,7 +39,6 @@
3939
"@babel/preset-react": "^7.24.7",
4040
"@babel/register": "^7.24.6",
4141
"@babel/runtime": "^7.24.8",
42-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
4342
"autoprefixer": "^10.4.19",
4443
"@babel/eslint-parser": "^7.24.8",
4544
"babel-loader": "^8.3.0",
@@ -53,7 +52,7 @@
5352
"html-webpack-plugin": "^5.6.0",
5453
"http-proxy": "^1.18.1",
5554
"json-loader": "^0.5.7",
56-
"layer-pack": "^2.3.9",
55+
"layer-pack": "^2.3.13",
5756
"mini-css-extract-plugin": "^1.6.2",
5857
"minimist": "^1.2.8",
5958
"null-loader": "^4.0.1",
@@ -66,6 +65,7 @@
6665
"postcss-mixins": "^7.0.3",
6766
"postcss-nested": "^5.0.6",
6867
"postcss-simple-vars": "^6.0.3",
68+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
6969
"react-refresh": "^0.14.2",
7070
"sass": "^1.77.8",
7171
"sass-loader": "^10.5.2",
@@ -76,6 +76,7 @@
7676
"svg-react-loader": "^0.4.6",
7777
"url-loader": "^4.1.1",
7878
"webpack": "^5.93.0",
79+
"webpack-cli": "^5.1.4",
7980
"webpack-bundle-analyzer": "^4.10.2",
8081
"webpack-dev-middleware": "^7.3.0",
8182
"webpack-dev-server": "^5.0.4"

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ lpack-setup
5050
- targetDir {String} : relative target build directory
5151
- production {bool} : build using production mode
5252
- extractCss {bool} : do extract css
53-
- babelInclude {regexp string} : optional regexp to force parsing external scripts
53+
- babelInclude {regexp string} : optional regexp to force parsing external scripts / mjs packages
5454
- babelPreset {object} : optional options for the babelPreset loader
5555
- TerserJSPlugin {object} : optional options for the TerserJSPlugin
5656
- HtmlWebpackPlugin {object} : optional options for HtmlWebpackPlugin

templates/SSRApp/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"react-dom": "^18.3.1"
1818
},
1919
"devDependencies": {
20-
"layer-pack": "^2.3.9",
21-
"lpack-react": "^2.0.8"
20+
"layer-pack": "^2.3.13",
21+
"lpack-react": "^2.1.1"
2222
}
2323
}

0 commit comments

Comments
 (0)