@s-ui/bundler 9.68.0 → 9.70.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
@@ -151,6 +151,14 @@ $ sui-bundler lib src/index.js -o umd/fancy -p http://my-cdn.com/fancy --umd="My
151
151
 
152
152
  Then you can find your library directly in the provided namespace variable: `window.MyFancyLibraryNamespace` or `window.MyFancyLibraryNamespace.default` for ES6 exports.
153
153
 
154
+ #### Use css chunks
155
+
156
+ You can use `--chunk-css` option for creating different chunks for each css file
157
+
158
+ ```
159
+ $ sui-bundler lib src/index.js -o umd/fancy -p http://my-cdn.com/fancy --chunk-css
160
+ ```
161
+
154
162
  ## Configuration
155
163
 
156
164
  This tool works with zero configuration out the box but you could use some configuration in order to optimize or adapt the output to your needs. For that, you need to add a property `sui-bundler` inside a `config` property in the package.json of your project.
@@ -17,6 +17,7 @@ program
17
17
  .option('-u, --umd [libraryName]', 'Whether to output library as umb')
18
18
  .option('-r, --root', 'Create build in root dir instead of version subdir')
19
19
  .option('-p, --path [path]', 'Absolute public path where files will be located.')
20
+ .option('--chunk-css', 'Bundle css in chunks')
20
21
  .on('--help', () =>
21
22
  console.log(`Examples:
22
23
  $ sui-bundler lib src/index.js -o umd/my-lib -p http://my-cdn.com/my-lib -C'
@@ -27,7 +28,7 @@ program
27
28
 
28
29
  const [entry] = program.args
29
30
  const options = program.opts()
30
- const {clean = false, output, umd = false, root = false} = options
31
+ const {clean = false, output, umd = false, root = false, chunkCss = false} = options
31
32
  const publicPath = options.path
32
33
 
33
34
  if (!output) {
@@ -46,7 +47,7 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
46
47
 
47
48
  const version = getPackageJson(process.cwd()).version
48
49
  const outputFolder = path.join(process.cwd(), output, path.sep, root ? '' : version)
49
- const webpackConfig = {...config, entry: path.resolve(process.cwd(), entry)}
50
+ const webpackConfig = {...config({chunkCss}), entry: path.resolve(process.cwd(), entry)}
50
51
  webpackConfig.output.publicPath = publicPath + (root ? '' : version + '/')
51
52
  webpackConfig.output.path = outputFolder
52
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s-ui/bundler",
3
- "version": "9.68.0",
3
+ "version": "9.70.0",
4
4
  "description": "Config-free bundler for ES6 React apps.",
5
5
  "bin": {
6
6
  "sui-bundler": "./bin/sui-bundler.js"
@@ -57,7 +57,7 @@
57
57
  "swc-loader": "0.2.6",
58
58
  "tailwindcss": "3.4.14",
59
59
  "url": "0.11.0",
60
- "webpack": "5.82.1",
60
+ "webpack": "5.94.0",
61
61
  "webpack-dev-server": "5.0.4",
62
62
  "webpack-manifest-plugin": "5.0.0",
63
63
  "webpack-node-externals": "3.0.0"
@@ -9,55 +9,58 @@ const sassRules = require('./shared/module-rules-sass.js')
9
9
  const {extractComments, sourceMap, supportLegacyBrowsers} = require('./shared/config.js')
10
10
  const {aliasFromConfig} = require('./shared/resolve-alias.js')
11
11
 
12
- const cssFileName = 'styles.css'
13
-
14
- module.exports = {
15
- mode: 'production',
16
- resolve: {
17
- alias: {
18
- ...aliasFromConfig
12
+ module.exports = ({chunkCss} = {}) => {
13
+ const chunkCssName = config.onlyHash ? '[contenthash:8].css' : '[name].[contenthash:8].css'
14
+ const cssFileName = chunkCss ? chunkCssName : 'styles.css'
15
+ return {
16
+ mode: 'production',
17
+ resolve: {
18
+ alias: {
19
+ ...aliasFromConfig
20
+ },
21
+ fallback: {
22
+ assert: false,
23
+ fs: false,
24
+ http: require.resolve('stream-http'),
25
+ https: require.resolve('https-browserify'),
26
+ path: false
27
+ },
28
+ extensions: ['.js', '.tsx', '.ts', '.json'],
29
+ modules: ['node_modules', path.resolve(process.cwd())]
30
+ },
31
+ entry: config.vendor
32
+ ? {
33
+ app: MAIN_ENTRY_POINT,
34
+ vendor: config.vendor
35
+ }
36
+ : MAIN_ENTRY_POINT,
37
+ target: 'web',
38
+ output: {
39
+ filename: 'index.js'
19
40
  },
20
- fallback: {
21
- assert: false,
22
- fs: false,
23
- http: require.resolve('stream-http'),
24
- https: require.resolve('https-browserify'),
25
- path: false
41
+ optimization: {
42
+ // avoid looping over all the modules after the compilation
43
+ checkWasmTypes: false,
44
+ minimize: true,
45
+ minimizer: [minifyJs({extractComments, sourceMap})]
26
46
  },
27
- extensions: ['.js', '.tsx', '.ts', '.json'],
28
- modules: ['node_modules', path.resolve(process.cwd())]
29
- },
30
- entry: config.vendor
31
- ? {
32
- app: MAIN_ENTRY_POINT,
33
- vendor: config.vendor
34
- }
35
- : MAIN_ENTRY_POINT,
36
- target: 'web',
37
- output: {
38
- filename: 'index.js'
39
- },
40
- optimization: {
41
- // avoid looping over all the modules after the compilation
42
- checkWasmTypes: false,
43
- minimize: true,
44
- minimizer: [minifyJs({extractComments, sourceMap})]
45
- },
46
- plugins: cleanList([
47
- new webpack.ProvidePlugin({
48
- process: 'process/browser.js'
49
- }),
50
- new MiniCssExtractPlugin({
51
- filename: cssFileName,
52
- chunkFilename: cssFileName
53
- }),
54
- new webpack.optimize.LimitChunkCountPlugin({
55
- maxChunks: 1
56
- }),
57
- new webpack.EnvironmentPlugin(envVars(config.env)),
58
- definePlugin()
59
- ]),
60
- module: {
61
- rules: [createCompilerRules({supportLegacyBrowsers}), sassRules]
47
+ plugins: cleanList([
48
+ new webpack.ProvidePlugin({
49
+ process: 'process/browser.js'
50
+ }),
51
+ new MiniCssExtractPlugin({
52
+ filename: cssFileName,
53
+ chunkFilename: cssFileName
54
+ }),
55
+ !chunkCss &&
56
+ new webpack.optimize.LimitChunkCountPlugin({
57
+ maxChunks: 1
58
+ }),
59
+ new webpack.EnvironmentPlugin(envVars(config.env)),
60
+ definePlugin()
61
+ ]),
62
+ module: {
63
+ rules: [createCompilerRules({supportLegacyBrowsers}), sassRules]
64
+ }
62
65
  }
63
66
  }