Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 170 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@
"stylelint": {
"extends": "./node_modules/@s-ui/lint/stylelint.config.js"
}
}
}
45 changes: 45 additions & 0 deletions packages/sui-bundler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,51 @@ There are two ways to activate the statics cache option:

> Statics will be cached but no offline page will be activated

### SVG Spritemaps

Generate SVG spritemaps by using [svg-spritemap-webpack-plugin](https://github.com/cascornelissen/svg-spritemap-webpack-plugin) as follows:

```json
{
"sui-bundler": {
"spritemaps": [
{
"path": ["icons/src/fotocasa/**/*.svg"],
"options": {
"output": {
"filename": "fotocasa.[contenthash].svg",
"chunk": {
"name": "fotocasa"
}
},
"sprite": {
"generate": {
"title": false
}
}
}
},
{
"path": ["icons/src/habitaclia/**/*.svg"],
"options": {
"output": {
"filename": "habitaclia.[contenthash].svg",
"chunk": {
"name": "habitaclia"
}
},
"sprite": {
"generate": {
"title": false
}
}
}
}
]
}
}
```

## Externals Manifest

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`).
Expand Down
7 changes: 4 additions & 3 deletions packages/sui-bundler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,21 @@
"html-webpack-plugin": "5.5.0",
"https-browserify": "1.0.0",
"mini-css-extract-plugin": "2.7.7",
"postcss-loader": "7.3.4",
"postcss": "8.4.31",
"postcss-loader": "7.3.4",
"process": "0.11.10",
"react-refresh": "0.14.0",
"sass": "1.54.5",
"stream-http": "3.2.0",
"strip-ansi": "6.0.1",
"style-loader": "3.3.4",
"svg-spritemap-webpack-plugin": "4.6.0",
"swc-loader": "0.2.6",
"tailwindcss": "3.4.14",
"url": "0.11.0",
"webpack": "5.82.1",
"webpack-dev-server": "5.0.4",
"webpack-manifest-plugin": "5.0.0",
"webpack-node-externals": "3.0.0",
"webpack": "5.82.1"
"webpack-node-externals": "3.0.0"
}
}
12 changes: 12 additions & 0 deletions packages/sui-bundler/shared/svg-spritemap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const SVGSpritemapPlugin = require('svg-spritemap-webpack-plugin')
const {config} = require('./config.js')

const createSVGSpritemapPlugin = () => {
const {spritemaps = []} = config

return spritemaps.map(({path, options = {}}) => {
return new SVGSpritemapPlugin(path, options)
})
}

module.exports = createSVGSpritemapPlugin
4 changes: 3 additions & 1 deletion packages/sui-bundler/webpack.config.client.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {withHydrationOverlayWebpack} = require('@builder.io/react-hydration-overl
const {envVars, MAIN_ENTRY_POINT, config, cleanList, when, isTailwindEnabled} = require('./shared/index.js')
const definePlugin = require('./shared/define.js')
const manifestLoaderRules = require('./shared/module-rules-manifest-loader.js')
const createSVGSpritemapPlugin = require('./shared/svg-spritemap')
const {aliasFromConfig, defaultAlias} = require('./shared/resolve-alias.js')
const {supportLegacyBrowsers, cacheDirectory} = require('./shared/config.js')

Expand Down Expand Up @@ -88,7 +89,8 @@ const webpackConfig = {
new ReactRefreshWebpackPlugin({overlay: false}),
new HtmlWebpackInjectAttributesPlugin({
crossorigin: 'anonymous'
})
}),
...createSVGSpritemapPlugin()
],
resolveLoader,
module: {
Expand Down
4 changes: 3 additions & 1 deletion packages/sui-bundler/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const {extractComments, sourceMap, supportLegacyBrowsers, cacheDirectory} = requ
const {resolveLoader} = require('./shared/resolve-loader.js')
const createCompilerRules = require('./shared/module-rules-compiler.js')
const sassRules = require('./shared/module-rules-sass.js')
const createSVGSpritemapPlugin = require('./shared/svg-spritemap')
const definePlugin = require('./shared/define.js')
const manifestLoaderRules = require('./shared/module-rules-manifest-loader.js')
const minifyCss = require('./shared/minify-css.js')
Expand Down Expand Up @@ -100,7 +101,8 @@ const webpackConfig = {
template: './index.html'
}),
new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/runtime/]),
new WebpackManifestPlugin({fileName: 'asset-manifest.json'})
new WebpackManifestPlugin({fileName: 'asset-manifest.json'}),
...createSVGSpritemapPlugin()
]),
module: {
rules: cleanList([
Expand Down