@s-ui/bundler 9.55.0 → 9.56.0-beta.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.
@@ -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.55.0",
3
+ "version": "9.56.0-beta.0",
4
4
  "description": "Config-free bundler for ES6 React apps.",
5
5
  "bin": {
6
6
  "sui-bundler": "./bin/sui-bundler.js"
package/shared/define.js CHANGED
@@ -8,6 +8,7 @@ if (process.platform === 'win32') {
8
8
 
9
9
  module.exports = (vars = {}) =>
10
10
  new webpack.DefinePlugin({
11
+ __MOCKS_API_PATH__: JSON.stringify(process.env.MOCKS_API_PATH || process.env.PWD + '/mocks/routes'),
11
12
  __DEV__: false,
12
13
  __BASE_DIR__: JSON.stringify(process.env.PWD),
13
14
  ...vars
@@ -1,6 +1,11 @@
1
1
  const webpack = require('webpack')
2
2
  const MiniCssExtractPlugin = require('mini-css-extract-plugin')
3
- const {cleanList, envVars, MAIN_ENTRY_POINT, config} = require('./shared/index.js')
3
+ const {
4
+ cleanList,
5
+ envVars,
6
+ MAIN_ENTRY_POINT,
7
+ config
8
+ } = require('./shared/index.js')
4
9
  const path = require('path')
5
10
  const minifyJs = require('./shared/minify-js.js')
6
11
  const definePlugin = require('./shared/define.js')
@@ -9,55 +14,59 @@ const sassRules = require('./shared/module-rules-sass.js')
9
14
  const {extractComments, sourceMap, supportLegacyBrowsers} = require('./shared/config.js')
10
15
  const {aliasFromConfig} = require('./shared/resolve-alias.js')
11
16
 
12
- const cssFileName = 'styles.css'
13
17
 
14
- module.exports = {
15
- mode: 'production',
16
- resolve: {
17
- alias: {
18
- ...aliasFromConfig
18
+ module.exports = ({
19
+ chunkCss
20
+ } = {}) => {
21
+ const cssFileName = chunkCss ? '[name].[contenthash:8].css' : 'styles.css'
22
+ return {
23
+ mode: 'production',
24
+ resolve: {
25
+ alias: {
26
+ ...aliasFromConfig
27
+ },
28
+ fallback: {
29
+ assert: false,
30
+ fs: false,
31
+ http: require.resolve('stream-http'),
32
+ https: require.resolve('https-browserify'),
33
+ path: false
34
+ },
35
+ extensions: ['.js', '.json'],
36
+ modules: ['node_modules', path.resolve(process.cwd())]
19
37
  },
20
- fallback: {
21
- assert: false,
22
- fs: false,
23
- http: require.resolve('stream-http'),
24
- https: require.resolve('https-browserify'),
25
- path: false
26
- },
27
- extensions: ['.js', '.json'],
28
- modules: ['node_modules', path.resolve(process.cwd())]
29
- },
30
- entry: config.vendor
31
- ? {
38
+ entry: config.vendor ?
39
+ {
32
40
  app: MAIN_ENTRY_POINT,
33
41
  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'
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: [createBabelRules({supportLegacyBrowsers}), sassRules]
42
+ } :
43
+ MAIN_ENTRY_POINT,
44
+ target: 'web',
45
+ output: {
46
+ filename: 'index.js'
47
+ },
48
+ optimization: {
49
+ // avoid looping over all the modules after the compilation
50
+ checkWasmTypes: false,
51
+ minimize: true,
52
+ minimizer: [minifyJs({extractComments, sourceMap})]
53
+ },
54
+ plugins: cleanList([
55
+ new webpack.ProvidePlugin({
56
+ process: 'process/browser'
57
+ }),
58
+ new MiniCssExtractPlugin({
59
+ filename: cssFileName,
60
+ chunkFilename: cssFileName
61
+ }),
62
+ !chunkCss && new webpack.optimize.LimitChunkCountPlugin({
63
+ maxChunks: 1
64
+ }),
65
+ new webpack.EnvironmentPlugin(envVars(config.env)),
66
+ definePlugin()
67
+ ]),
68
+ module: {
69
+ rules: [createBabelRules({supportLegacyBrowsers}), sassRules]
70
+ }
62
71
  }
63
- }
72
+ }