@s-ui/bundler 9.66.0 → 9.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -227,6 +227,51 @@ There are two ways to activate the statics cache option:
227
227
 
228
228
  > Statics will be cached but no offline page will be activated
229
229
 
230
+ ### SVG Spritemaps
231
+
232
+ Generate SVG spritemaps by using [svg-spritemap-webpack-plugin](https://github.com/cascornelissen/svg-spritemap-webpack-plugin) as follows:
233
+
234
+ ```json
235
+ {
236
+ "sui-bundler": {
237
+ "spritemaps": [
238
+ {
239
+ "path": ["icons/src/fotocasa/**/*.svg"],
240
+ "options": {
241
+ "output": {
242
+ "filename": "fotocasa.[contenthash].svg",
243
+ "chunk": {
244
+ "name": "fotocasa"
245
+ }
246
+ },
247
+ "sprite": {
248
+ "generate": {
249
+ "title": false
250
+ }
251
+ }
252
+ }
253
+ },
254
+ {
255
+ "path": ["icons/src/habitaclia/**/*.svg"],
256
+ "options": {
257
+ "output": {
258
+ "filename": "habitaclia.[contenthash].svg",
259
+ "chunk": {
260
+ "name": "habitaclia"
261
+ }
262
+ },
263
+ "sprite": {
264
+ "generate": {
265
+ "title": false
266
+ }
267
+ }
268
+ }
269
+ }
270
+ ]
271
+ }
272
+ }
273
+ ```
274
+
230
275
  ## Externals Manifest
231
276
 
232
277
  If your are using an external CDN to store statics assets that are now managed by Webpack, like SVG or IMGs, you can create a manifest.json file in the root of your CDN (likehttps://spa-mock-statics.surge.sh/manifest.json`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s-ui/bundler",
3
- "version": "9.66.0",
3
+ "version": "9.68.0",
4
4
  "description": "Config-free bundler for ES6 React apps.",
5
5
  "bin": {
6
6
  "sui-bundler": "./bin/sui-bundler.js"
@@ -45,19 +45,21 @@
45
45
  "html-webpack-plugin": "5.5.0",
46
46
  "https-browserify": "1.0.0",
47
47
  "mini-css-extract-plugin": "2.7.7",
48
- "postcss-loader": "7.3.4",
49
48
  "postcss": "8.4.31",
49
+ "postcss-loader": "7.3.4",
50
50
  "process": "0.11.10",
51
51
  "react-refresh": "0.14.0",
52
52
  "sass": "1.54.5",
53
53
  "stream-http": "3.2.0",
54
54
  "strip-ansi": "6.0.1",
55
55
  "style-loader": "3.3.4",
56
+ "svg-spritemap-webpack-plugin": "4.6.0",
56
57
  "swc-loader": "0.2.6",
58
+ "tailwindcss": "3.4.14",
57
59
  "url": "0.11.0",
60
+ "webpack": "5.82.1",
58
61
  "webpack-dev-server": "5.0.4",
59
62
  "webpack-manifest-plugin": "5.0.0",
60
- "webpack-node-externals": "3.0.0",
61
- "webpack": "5.82.1"
63
+ "webpack-node-externals": "3.0.0"
62
64
  }
63
65
  }
package/shared/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ const fs = require('fs')
1
2
  const {config} = require('./config.js')
2
3
 
3
4
  exports.MAIN_ENTRY_POINT = './app'
@@ -7,6 +8,8 @@ exports.cleanList = list => list.filter(Boolean)
7
8
 
8
9
  exports.when = (check, getValue) => (check ? getValue() : false)
9
10
 
11
+ exports.isTailwindEnabled = () => fs.existsSync(`${process.cwd()}/tailwind.config.js`)
12
+
10
13
  exports.envVars = (env = []) =>
11
14
  env.reduce(
12
15
  (acc, variable) => {
@@ -1,6 +1,6 @@
1
1
  const MiniCssExtractPlugin = require('mini-css-extract-plugin')
2
2
 
3
- const {cleanList, config, when} = require('./index')
3
+ const {cleanList, config, when, isTailwindEnabled} = require('./index')
4
4
 
5
5
  module.exports = {
6
6
  test: /(\.css|\.scss)$/,
@@ -18,6 +18,7 @@ module.exports = {
18
18
  options: {
19
19
  postcssOptions: {
20
20
  plugins: [
21
+ ...(isTailwindEnabled() ? [require('tailwindcss')()] : []),
21
22
  require('autoprefixer')({
22
23
  overrideBrowserslist: config.targets
23
24
  })
@@ -0,0 +1,12 @@
1
+ const SVGSpritemapPlugin = require('svg-spritemap-webpack-plugin')
2
+ const {config} = require('./config.js')
3
+
4
+ const createSVGSpritemapPlugin = () => {
5
+ const {spritemaps = []} = config
6
+
7
+ return spritemaps.map(({path, options = {}}) => {
8
+ return new SVGSpritemapPlugin(path, options)
9
+ })
10
+ }
11
+
12
+ module.exports = createSVGSpritemapPlugin
@@ -9,9 +9,10 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
9
9
  const HtmlWebpackInjectAttributesPlugin = require('html-webpack-inject-attributes-plugin')
10
10
  const {withHydrationOverlayWebpack} = require('@builder.io/react-hydration-overlay/webpack')
11
11
 
12
- const {envVars, MAIN_ENTRY_POINT, config, cleanList, when} = require('./shared/index.js')
12
+ const {envVars, MAIN_ENTRY_POINT, config, cleanList, when, isTailwindEnabled} = require('./shared/index.js')
13
13
  const definePlugin = require('./shared/define.js')
14
14
  const manifestLoaderRules = require('./shared/module-rules-manifest-loader.js')
15
+ const createSVGSpritemapPlugin = require('./shared/svg-spritemap')
15
16
  const {aliasFromConfig, defaultAlias} = require('./shared/resolve-alias.js')
16
17
  const {supportLegacyBrowsers, cacheDirectory} = require('./shared/config.js')
17
18
 
@@ -88,7 +89,8 @@ const webpackConfig = {
88
89
  new ReactRefreshWebpackPlugin({overlay: false}),
89
90
  new HtmlWebpackInjectAttributesPlugin({
90
91
  crossorigin: 'anonymous'
91
- })
92
+ }),
93
+ ...createSVGSpritemapPlugin()
92
94
  ],
93
95
  resolveLoader,
94
96
  module: {
@@ -110,6 +112,7 @@ const webpackConfig = {
110
112
  options: {
111
113
  postcssOptions: {
112
114
  plugins: [
115
+ ...(isTailwindEnabled() ? [require('tailwindcss')()] : []),
113
116
  require('autoprefixer')({
114
117
  overrideBrowserslist: config.targets
115
118
  })
@@ -5,7 +5,7 @@ const webpack = require('webpack')
5
5
  const HtmlWebpackPlugin = require('html-webpack-plugin')
6
6
  const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
7
7
 
8
- const {envVars, MAIN_ENTRY_POINT, config, cleanList, when} = require('./shared/index.js')
8
+ const {envVars, MAIN_ENTRY_POINT, config, cleanList, when, isTailwindEnabled} = require('./shared/index.js')
9
9
  const definePlugin = require('./shared/define.js')
10
10
  const manifestLoaderRules = require('./shared/module-rules-manifest-loader.js')
11
11
  const {aliasFromConfig, defaultAlias} = require('./shared/resolve-alias.js')
@@ -104,6 +104,7 @@ const webpackConfig = {
104
104
  options: {
105
105
  postcssOptions: {
106
106
  plugins: [
107
+ ...(isTailwindEnabled() ? [require('tailwindcss')()] : []),
107
108
  require('autoprefixer')({
108
109
  overrideBrowserslist: config.targets
109
110
  })
@@ -15,6 +15,7 @@ const {extractComments, sourceMap, supportLegacyBrowsers, cacheDirectory} = requ
15
15
  const {resolveLoader} = require('./shared/resolve-loader.js')
16
16
  const createCompilerRules = require('./shared/module-rules-compiler.js')
17
17
  const sassRules = require('./shared/module-rules-sass.js')
18
+ const createSVGSpritemapPlugin = require('./shared/svg-spritemap')
18
19
  const definePlugin = require('./shared/define.js')
19
20
  const manifestLoaderRules = require('./shared/module-rules-manifest-loader.js')
20
21
  const minifyCss = require('./shared/minify-css.js')
@@ -100,7 +101,8 @@ const webpackConfig = {
100
101
  template: './index.html'
101
102
  }),
102
103
  new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/runtime/]),
103
- new WebpackManifestPlugin({fileName: 'asset-manifest.json'})
104
+ new WebpackManifestPlugin({fileName: 'asset-manifest.json'}),
105
+ ...createSVGSpritemapPlugin()
104
106
  ]),
105
107
  module: {
106
108
  rules: cleanList([