tiny-lite-sys 0.0.1

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.
Files changed (177) hide show
  1. checksums.yaml +7 -0
  2. data/tiny-lite-sys.gemspec +11 -0
  3. data/webpacker-5.4.4/CHANGELOG.md +1074 -0
  4. data/webpacker-5.4.4/CONTRIBUTING.md +33 -0
  5. data/webpacker-5.4.4/Gemfile +13 -0
  6. data/webpacker-5.4.4/Gemfile.lock +183 -0
  7. data/webpacker-5.4.4/MIT-LICENSE +20 -0
  8. data/webpacker-5.4.4/README.md +427 -0
  9. data/webpacker-5.4.4/Rakefile +11 -0
  10. data/webpacker-5.4.4/docs/assets.md +119 -0
  11. data/webpacker-5.4.4/docs/cloud9.md +310 -0
  12. data/webpacker-5.4.4/docs/css.md +308 -0
  13. data/webpacker-5.4.4/docs/deployment.md +130 -0
  14. data/webpacker-5.4.4/docs/docker.md +68 -0
  15. data/webpacker-5.4.4/docs/engines.md +213 -0
  16. data/webpacker-5.4.4/docs/env.md +63 -0
  17. data/webpacker-5.4.4/docs/es6.md +72 -0
  18. data/webpacker-5.4.4/docs/folder-structure.md +66 -0
  19. data/webpacker-5.4.4/docs/integrations.md +220 -0
  20. data/webpacker-5.4.4/docs/misc.md +23 -0
  21. data/webpacker-5.4.4/docs/props.md +223 -0
  22. data/webpacker-5.4.4/docs/target.md +22 -0
  23. data/webpacker-5.4.4/docs/testing.md +136 -0
  24. data/webpacker-5.4.4/docs/troubleshooting.md +158 -0
  25. data/webpacker-5.4.4/docs/typescript.md +190 -0
  26. data/webpacker-5.4.4/docs/v4-upgrade.md +142 -0
  27. data/webpacker-5.4.4/docs/webpack-dev-server.md +92 -0
  28. data/webpacker-5.4.4/docs/webpack.md +364 -0
  29. data/webpacker-5.4.4/docs/yarn.md +23 -0
  30. data/webpacker-5.4.4/gemfiles/Gemfile-rails-edge +12 -0
  31. data/webpacker-5.4.4/gemfiles/Gemfile-rails.5.2.x +9 -0
  32. data/webpacker-5.4.4/gemfiles/Gemfile-rails.6.0.x +9 -0
  33. data/webpacker-5.4.4/lib/install/angular.rb +23 -0
  34. data/webpacker-5.4.4/lib/install/bin/webpack +18 -0
  35. data/webpacker-5.4.4/lib/install/bin/webpack-dev-server +18 -0
  36. data/webpacker-5.4.4/lib/install/binstubs.rb +4 -0
  37. data/webpacker-5.4.4/lib/install/coffee.rb +25 -0
  38. data/webpacker-5.4.4/lib/install/config/babel.config.js +82 -0
  39. data/webpacker-5.4.4/lib/install/config/postcss.config.js +12 -0
  40. data/webpacker-5.4.4/lib/install/config/webpack/development.js +5 -0
  41. data/webpacker-5.4.4/lib/install/config/webpack/environment.js +3 -0
  42. data/webpacker-5.4.4/lib/install/config/webpack/production.js +5 -0
  43. data/webpacker-5.4.4/lib/install/config/webpack/test.js +5 -0
  44. data/webpacker-5.4.4/lib/install/config/webpacker.yml +92 -0
  45. data/webpacker-5.4.4/lib/install/elm.rb +39 -0
  46. data/webpacker-5.4.4/lib/install/erb.rb +25 -0
  47. data/webpacker-5.4.4/lib/install/examples/angular/hello_angular/app/app.component.ts +9 -0
  48. data/webpacker-5.4.4/lib/install/examples/angular/hello_angular/app/app.module.ts +16 -0
  49. data/webpacker-5.4.4/lib/install/examples/angular/hello_angular/index.ts +8 -0
  50. data/webpacker-5.4.4/lib/install/examples/angular/hello_angular/polyfills.ts +73 -0
  51. data/webpacker-5.4.4/lib/install/examples/angular/hello_angular.js +7 -0
  52. data/webpacker-5.4.4/lib/install/examples/coffee/hello_coffee.coffee +4 -0
  53. data/webpacker-5.4.4/lib/install/examples/elm/Main.elm +55 -0
  54. data/webpacker-5.4.4/lib/install/examples/elm/hello_elm.js +16 -0
  55. data/webpacker-5.4.4/lib/install/examples/erb/hello_erb.js.erb +6 -0
  56. data/webpacker-5.4.4/lib/install/examples/react/babel.config.js +99 -0
  57. data/webpacker-5.4.4/lib/install/examples/react/hello_react.jsx +26 -0
  58. data/webpacker-5.4.4/lib/install/examples/react/tsconfig.json +21 -0
  59. data/webpacker-5.4.4/lib/install/examples/stimulus/application.js +1 -0
  60. data/webpacker-5.4.4/lib/install/examples/stimulus/controllers/hello_controller.js +18 -0
  61. data/webpacker-5.4.4/lib/install/examples/stimulus/controllers/index.js +9 -0
  62. data/webpacker-5.4.4/lib/install/examples/svelte/app.svelte +11 -0
  63. data/webpacker-5.4.4/lib/install/examples/svelte/hello_svelte.js +20 -0
  64. data/webpacker-5.4.4/lib/install/examples/typescript/hello_typescript.ts +4 -0
  65. data/webpacker-5.4.4/lib/install/examples/typescript/tsconfig.json +24 -0
  66. data/webpacker-5.4.4/lib/install/examples/vue/app.vue +22 -0
  67. data/webpacker-5.4.4/lib/install/examples/vue/hello_vue.js +72 -0
  68. data/webpacker-5.4.4/lib/install/javascript/packs/application.js +18 -0
  69. data/webpacker-5.4.4/lib/install/loaders/coffee.js +6 -0
  70. data/webpacker-5.4.4/lib/install/loaders/elm.js +25 -0
  71. data/webpacker-5.4.4/lib/install/loaders/erb.js +11 -0
  72. data/webpacker-5.4.4/lib/install/loaders/svelte.js +9 -0
  73. data/webpacker-5.4.4/lib/install/loaders/vue.js +6 -0
  74. data/webpacker-5.4.4/lib/install/react.rb +18 -0
  75. data/webpacker-5.4.4/lib/install/stimulus.rb +12 -0
  76. data/webpacker-5.4.4/lib/install/svelte.rb +29 -0
  77. data/webpacker-5.4.4/lib/install/template.rb +63 -0
  78. data/webpacker-5.4.4/lib/install/typescript.rb +39 -0
  79. data/webpacker-5.4.4/lib/install/vue.rb +49 -0
  80. data/webpacker-5.4.4/lib/tasks/installers.rake +42 -0
  81. data/webpacker-5.4.4/lib/tasks/webpacker/binstubs.rake +13 -0
  82. data/webpacker-5.4.4/lib/tasks/webpacker/check_binstubs.rake +12 -0
  83. data/webpacker-5.4.4/lib/tasks/webpacker/check_node.rake +31 -0
  84. data/webpacker-5.4.4/lib/tasks/webpacker/check_yarn.rake +30 -0
  85. data/webpacker-5.4.4/lib/tasks/webpacker/clean.rake +25 -0
  86. data/webpacker-5.4.4/lib/tasks/webpacker/clobber.rake +20 -0
  87. data/webpacker-5.4.4/lib/tasks/webpacker/compile.rake +43 -0
  88. data/webpacker-5.4.4/lib/tasks/webpacker/info.rake +19 -0
  89. data/webpacker-5.4.4/lib/tasks/webpacker/install.rake +13 -0
  90. data/webpacker-5.4.4/lib/tasks/webpacker/verify_install.rake +13 -0
  91. data/webpacker-5.4.4/lib/tasks/webpacker/yarn_install.rake +16 -0
  92. data/webpacker-5.4.4/lib/tasks/webpacker.rake +28 -0
  93. data/webpacker-5.4.4/lib/webpacker/commands.rb +74 -0
  94. data/webpacker-5.4.4/lib/webpacker/compiler.rb +111 -0
  95. data/webpacker-5.4.4/lib/webpacker/configuration.rb +128 -0
  96. data/webpacker-5.4.4/lib/webpacker/dev_server.rb +66 -0
  97. data/webpacker-5.4.4/lib/webpacker/dev_server_proxy.rb +33 -0
  98. data/webpacker-5.4.4/lib/webpacker/dev_server_runner.rb +72 -0
  99. data/webpacker-5.4.4/lib/webpacker/env.rb +43 -0
  100. data/webpacker-5.4.4/lib/webpacker/helper.rb +195 -0
  101. data/webpacker-5.4.4/lib/webpacker/instance.rb +37 -0
  102. data/webpacker-5.4.4/lib/webpacker/manifest.rb +118 -0
  103. data/webpacker-5.4.4/lib/webpacker/railtie.rb +55 -0
  104. data/webpacker-5.4.4/lib/webpacker/runner.rb +23 -0
  105. data/webpacker-5.4.4/lib/webpacker/version.rb +4 -0
  106. data/webpacker-5.4.4/lib/webpacker/webpack_runner.rb +32 -0
  107. data/webpacker-5.4.4/lib/webpacker.rb +46 -0
  108. data/webpacker-5.4.4/package/__tests__/config.js +66 -0
  109. data/webpacker-5.4.4/package/__tests__/dev_server.js +45 -0
  110. data/webpacker-5.4.4/package/__tests__/development.js +43 -0
  111. data/webpacker-5.4.4/package/__tests__/env.js +46 -0
  112. data/webpacker-5.4.4/package/__tests__/production.js +29 -0
  113. data/webpacker-5.4.4/package/__tests__/staging.js +29 -0
  114. data/webpacker-5.4.4/package/__tests__/test.js +26 -0
  115. data/webpacker-5.4.4/package/config.js +40 -0
  116. data/webpacker-5.4.4/package/configPath.js +3 -0
  117. data/webpacker-5.4.4/package/config_types/__tests__/config_list.js +118 -0
  118. data/webpacker-5.4.4/package/config_types/__tests__/config_object.js +43 -0
  119. data/webpacker-5.4.4/package/config_types/config_list.js +75 -0
  120. data/webpacker-5.4.4/package/config_types/config_object.js +55 -0
  121. data/webpacker-5.4.4/package/config_types/index.js +7 -0
  122. data/webpacker-5.4.4/package/dev_server.js +20 -0
  123. data/webpacker-5.4.4/package/env.js +18 -0
  124. data/webpacker-5.4.4/package/environments/__tests__/base.js +101 -0
  125. data/webpacker-5.4.4/package/environments/base.js +176 -0
  126. data/webpacker-5.4.4/package/environments/development.js +53 -0
  127. data/webpacker-5.4.4/package/environments/production.js +77 -0
  128. data/webpacker-5.4.4/package/environments/test.js +3 -0
  129. data/webpacker-5.4.4/package/index.js +24 -0
  130. data/webpacker-5.4.4/package/rules/babel.js +28 -0
  131. data/webpacker-5.4.4/package/rules/css.js +3 -0
  132. data/webpacker-5.4.4/package/rules/file.js +21 -0
  133. data/webpacker-5.4.4/package/rules/index.js +20 -0
  134. data/webpacker-5.4.4/package/rules/module.css.js +3 -0
  135. data/webpacker-5.4.4/package/rules/module.sass.js +8 -0
  136. data/webpacker-5.4.4/package/rules/node_modules.js +22 -0
  137. data/webpacker-5.4.4/package/rules/sass.js +17 -0
  138. data/webpacker-5.4.4/package/utils/__tests__/deep_assign.js +32 -0
  139. data/webpacker-5.4.4/package/utils/__tests__/deep_merge.js +10 -0
  140. data/webpacker-5.4.4/package/utils/__tests__/get_style_rule.js +65 -0
  141. data/webpacker-5.4.4/package/utils/__tests__/objectify.js +9 -0
  142. data/webpacker-5.4.4/package/utils/deep_assign.js +22 -0
  143. data/webpacker-5.4.4/package/utils/deep_merge.js +22 -0
  144. data/webpacker-5.4.4/package/utils/get_style_rule.js +45 -0
  145. data/webpacker-5.4.4/package/utils/helpers.js +58 -0
  146. data/webpacker-5.4.4/package/utils/objectify.js +3 -0
  147. data/webpacker-5.4.4/package.json +82 -0
  148. data/webpacker-5.4.4/test/command_test.rb +33 -0
  149. data/webpacker-5.4.4/test/compiler_test.rb +80 -0
  150. data/webpacker-5.4.4/test/configuration_test.rb +109 -0
  151. data/webpacker-5.4.4/test/dev_server_runner_test.rb +51 -0
  152. data/webpacker-5.4.4/test/dev_server_test.rb +47 -0
  153. data/webpacker-5.4.4/test/env_test.rb +23 -0
  154. data/webpacker-5.4.4/test/helper_test.rb +157 -0
  155. data/webpacker-5.4.4/test/manifest_test.rb +73 -0
  156. data/webpacker-5.4.4/test/rake_tasks_test.rb +80 -0
  157. data/webpacker-5.4.4/test/test_app/Rakefile +3 -0
  158. data/webpacker-5.4.4/test/test_app/app/javascript/packs/application.js +10 -0
  159. data/webpacker-5.4.4/test/test_app/app/javascript/packs/multi_entry.css +4 -0
  160. data/webpacker-5.4.4/test/test_app/app/javascript/packs/multi_entry.js +4 -0
  161. data/webpacker-5.4.4/test/test_app/bin/webpack +14 -0
  162. data/webpacker-5.4.4/test/test_app/bin/webpack-dev-server +14 -0
  163. data/webpacker-5.4.4/test/test_app/config/application.rb +11 -0
  164. data/webpacker-5.4.4/test/test_app/config/environment.rb +4 -0
  165. data/webpacker-5.4.4/test/test_app/config/webpack/development.js +0 -0
  166. data/webpacker-5.4.4/test/test_app/config/webpacker.yml +103 -0
  167. data/webpacker-5.4.4/test/test_app/config/webpacker_public_root.yml +19 -0
  168. data/webpacker-5.4.4/test/test_app/config.ru +5 -0
  169. data/webpacker-5.4.4/test/test_app/package.json +13 -0
  170. data/webpacker-5.4.4/test/test_app/public/packs/manifest.json +32 -0
  171. data/webpacker-5.4.4/test/test_app/yarn.lock +11 -0
  172. data/webpacker-5.4.4/test/test_helper.rb +33 -0
  173. data/webpacker-5.4.4/test/webpack_runner_test.rb +51 -0
  174. data/webpacker-5.4.4/test/webpacker_test.rb +13 -0
  175. data/webpacker-5.4.4/webpacker.gemspec +31 -0
  176. data/webpacker-5.4.4/yarn.lock +8271 -0
  177. metadata +215 -0
@@ -0,0 +1,176 @@
1
+ /* eslint global-require: 0 */
2
+ /* eslint import/no-dynamic-require: 0 */
3
+
4
+ const {
5
+ basename, dirname, join, relative, resolve
6
+ } = require('path')
7
+ const { sync } = require('glob')
8
+ const extname = require('path-complete-extname')
9
+
10
+ const webpack = require('webpack')
11
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
12
+ const WebpackAssetsManifest = require('webpack-assets-manifest')
13
+ const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
14
+ const PnpWebpackPlugin = require('pnp-webpack-plugin')
15
+
16
+ const { isNotObject, prettyPrint } = require('../utils/helpers')
17
+ const deepMerge = require('../utils/deep_merge')
18
+
19
+ const { ConfigList, ConfigObject } = require('../config_types')
20
+ const rules = require('../rules')
21
+ const config = require('../config')
22
+
23
+ const getLoaderList = () => {
24
+ const result = new ConfigList()
25
+ Object.keys(rules).forEach((key) => result.append(key, rules[key]))
26
+ return result
27
+ }
28
+
29
+ const getPluginList = () => {
30
+ const result = new ConfigList()
31
+ result.append(
32
+ 'Environment',
33
+ new webpack.EnvironmentPlugin(process.env)
34
+ )
35
+ result.append('CaseSensitivePaths', new CaseSensitivePathsPlugin())
36
+ result.append(
37
+ 'MiniCssExtract',
38
+ new MiniCssExtractPlugin({
39
+ filename: 'css/[name]-[contenthash:8].css',
40
+ chunkFilename: 'css/[name]-[contenthash:8].chunk.css'
41
+ })
42
+ )
43
+ result.append(
44
+ 'Manifest',
45
+ new WebpackAssetsManifest({
46
+ entrypoints: true,
47
+ writeToDisk: true,
48
+ publicPath: config.publicPathWithoutCDN
49
+ })
50
+ )
51
+ return result
52
+ }
53
+
54
+ const getExtensionsGlob = () => {
55
+ const { extensions } = config
56
+ return extensions.length === 1 ? `**/*${extensions[0]}` : `**/*{${extensions.join(',')}}`
57
+ }
58
+
59
+ const getEntryObject = () => {
60
+ const result = new ConfigObject()
61
+ const glob = getExtensionsGlob()
62
+ const rootPath = join(config.source_path, config.source_entry_path)
63
+ const paths = sync(join(rootPath, glob))
64
+ paths.forEach((path) => {
65
+ const namespace = relative(join(rootPath), dirname(path))
66
+ const name = join(namespace, basename(path, extname(path)))
67
+ let assetPaths = resolve(path)
68
+
69
+ // Allows for multiple filetypes per entry (https://webpack.js.org/guides/entry-advanced/)
70
+ // Transforms the config object value to an array with all values under the same name
71
+ let previousPaths = result.get(name)
72
+ if (previousPaths) {
73
+ previousPaths = Array.isArray(previousPaths) ? previousPaths : [previousPaths]
74
+ previousPaths.push(assetPaths)
75
+ assetPaths = previousPaths
76
+ }
77
+
78
+ result.set(name, assetPaths)
79
+ })
80
+ return result
81
+ }
82
+
83
+ const getModulePaths = () => {
84
+ const result = new ConfigList()
85
+ result.append('source', resolve(config.source_path))
86
+ if (config.additional_paths) {
87
+ config.additional_paths.forEach((path) => result.append(path, resolve(path)))
88
+ }
89
+ result.append('node_modules', 'node_modules')
90
+ return result
91
+ }
92
+
93
+ const getBaseConfig = () => new ConfigObject({
94
+ mode: 'production',
95
+ output: {
96
+ filename: 'js/[name]-[contenthash].js',
97
+ chunkFilename: 'js/[name]-[contenthash].chunk.js',
98
+ hotUpdateChunkFilename: 'js/[id]-[hash].hot-update.js',
99
+ path: config.outputPath,
100
+ publicPath: config.publicPath
101
+ },
102
+
103
+ resolve: {
104
+ extensions: config.extensions,
105
+ plugins: [PnpWebpackPlugin]
106
+ },
107
+
108
+ resolveLoader: {
109
+ modules: ['node_modules'],
110
+ plugins: [PnpWebpackPlugin.moduleLoader(module)]
111
+ },
112
+
113
+ node: {
114
+ dgram: 'empty',
115
+ fs: 'empty',
116
+ net: 'empty',
117
+ tls: 'empty',
118
+ child_process: 'empty'
119
+ }
120
+ })
121
+
122
+ module.exports = class Base {
123
+ constructor() {
124
+ this.loaders = getLoaderList()
125
+ this.plugins = getPluginList()
126
+ this.config = getBaseConfig()
127
+ this.entry = getEntryObject()
128
+ this.resolvedModules = getModulePaths()
129
+ }
130
+
131
+ splitChunks(callback = null) {
132
+ let appConfig = {}
133
+ const defaultConfig = {
134
+ optimization: {
135
+ // Split vendor and common chunks
136
+ // https://twitter.com/wSokra/status/969633336732905474
137
+ splitChunks: {
138
+ chunks: 'all',
139
+ name: true
140
+ },
141
+ // Separate runtime chunk to enable long term caching
142
+ // https://twitter.com/wSokra/status/969679223278505985
143
+ runtimeChunk: true
144
+ }
145
+ }
146
+
147
+ if (callback) {
148
+ appConfig = callback(defaultConfig)
149
+ if (isNotObject(appConfig)) {
150
+ throw new Error(`
151
+ ${prettyPrint(appConfig)} is not a valid splitChunks configuration.
152
+ See https://webpack.js.org/plugins/split-chunks-plugin/#configuration
153
+ `)
154
+ }
155
+ }
156
+
157
+ return this.config.merge(deepMerge(defaultConfig, appConfig))
158
+ }
159
+
160
+ toWebpackConfig() {
161
+ return this.config.merge({
162
+ entry: this.entry.toObject(),
163
+
164
+ module: {
165
+ strictExportPresence: true,
166
+ rules: this.loaders.values()
167
+ },
168
+
169
+ plugins: this.plugins.values(),
170
+
171
+ resolve: {
172
+ modules: this.resolvedModules.values()
173
+ }
174
+ })
175
+ }
176
+ }
@@ -0,0 +1,53 @@
1
+ const webpack = require('webpack')
2
+ const Base = require('./base')
3
+ const devServer = require('../dev_server')
4
+ const { outputPath: contentBase, publicPath } = require('../config')
5
+
6
+ module.exports = class extends Base {
7
+ constructor() {
8
+ super()
9
+
10
+ this.config.merge({
11
+ mode: 'development',
12
+ devtool: 'cheap-module-source-map'
13
+ })
14
+
15
+ if (process.env.WEBPACK_DEV_SERVER
16
+ && process.env.WEBPACK_DEV_SERVER !== 'undefined') {
17
+ if (devServer.hmr) {
18
+ this.plugins.append('HotModuleReplacement', new webpack.HotModuleReplacementPlugin())
19
+ this.config.output.filename = '[name]-[hash].js'
20
+ }
21
+
22
+ this.config.merge({
23
+ devServer: {
24
+ clientLogLevel: 'none',
25
+ compress: devServer.compress,
26
+ quiet: devServer.quiet,
27
+ disableHostCheck: devServer.disable_host_check,
28
+ host: devServer.host,
29
+ port: devServer.port,
30
+ https: devServer.https,
31
+ hot: devServer.hmr,
32
+ contentBase,
33
+ inline: devServer.inline,
34
+ useLocalIp: devServer.use_local_ip,
35
+ public: devServer.public,
36
+ publicPath,
37
+ historyApiFallback: {
38
+ disableDotRule: true
39
+ },
40
+ headers: devServer.headers,
41
+ overlay: devServer.overlay,
42
+ stats: {
43
+ entrypoints: false,
44
+ errorDetails: true,
45
+ modules: false,
46
+ moduleTrace: false
47
+ },
48
+ watchOptions: devServer.watch_options
49
+ }
50
+ })
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,77 @@
1
+ const TerserPlugin = require('terser-webpack-plugin')
2
+ const CompressionPlugin = require('compression-webpack-plugin')
3
+ const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
4
+ const safePostCssParser = require('postcss-safe-parser')
5
+ const Base = require('./base')
6
+
7
+ module.exports = class extends Base {
8
+ constructor() {
9
+ super()
10
+
11
+ this.plugins.append(
12
+ 'Compression',
13
+ new CompressionPlugin({
14
+ filename: '[path].gz[query]',
15
+ algorithm: 'gzip',
16
+ test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/
17
+ })
18
+ )
19
+
20
+ if ('brotli' in process.versions) {
21
+ this.plugins.append(
22
+ 'Compression Brotli',
23
+ new CompressionPlugin({
24
+ filename: '[path].br[query]',
25
+ algorithm: 'brotliCompress',
26
+ test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/
27
+ })
28
+ )
29
+ }
30
+
31
+ this.plugins.append(
32
+ 'OptimizeCSSAssets',
33
+ new OptimizeCSSAssetsPlugin({
34
+ parser: safePostCssParser,
35
+ map: {
36
+ inline: false,
37
+ annotation: true
38
+ }
39
+ })
40
+ )
41
+
42
+ this.config.merge({
43
+ devtool: 'source-map',
44
+ stats: 'normal',
45
+ bail: true,
46
+ optimization: {
47
+ minimizer: [
48
+ new TerserPlugin({
49
+ parallel: Number.parseInt(process.env.WEBPACKER_PARALLEL, 10) || true,
50
+ cache: true,
51
+ sourceMap: true,
52
+ terserOptions: {
53
+ parse: {
54
+ // Let terser parse ecma 8 code but always output
55
+ // ES5 compliant code for older browsers
56
+ ecma: 8
57
+ },
58
+ compress: {
59
+ ecma: 5,
60
+ warnings: false,
61
+ comparisons: false
62
+ },
63
+ mangle: {
64
+ safari10: true
65
+ },
66
+ output: {
67
+ ecma: 5,
68
+ comments: false,
69
+ ascii_only: true
70
+ }
71
+ }
72
+ })
73
+ ]
74
+ }
75
+ })
76
+ }
77
+ }
@@ -0,0 +1,3 @@
1
+ const Base = require('./base')
2
+
3
+ module.exports = class extends Base {}
@@ -0,0 +1,24 @@
1
+ /* eslint global-require: 0 */
2
+ /* eslint import/no-dynamic-require: 0 */
3
+
4
+ const { resolve } = require('path')
5
+ const { existsSync } = require('fs')
6
+ const Environment = require('./environments/base')
7
+ const loaders = require('./rules')
8
+ const config = require('./config')
9
+ const devServer = require('./dev_server')
10
+ const { nodeEnv } = require('./env')
11
+
12
+ const createEnvironment = () => {
13
+ const path = resolve(__dirname, 'environments', `${nodeEnv}.js`)
14
+ const constructor = existsSync(path) ? require(path) : Environment
15
+ return new constructor()
16
+ }
17
+
18
+ module.exports = {
19
+ config,
20
+ devServer,
21
+ environment: createEnvironment(),
22
+ Environment,
23
+ loaders
24
+ }
@@ -0,0 +1,28 @@
1
+ const { resolve } = require('path')
2
+ const { realpathSync } = require('fs')
3
+ const { source_path: sourcePath, additional_paths: additionalPaths } = require('../config')
4
+ const { nodeEnv } = require('../env')
5
+
6
+ // Process application Javascript code with Babel.
7
+ // Uses application .babelrc to apply any transformations
8
+ module.exports = {
9
+ test: /\.(js|jsx|mjs|ts|tsx)?(\.erb)?$/,
10
+ include: [sourcePath, ...additionalPaths].map((p) => {
11
+ try {
12
+ return realpathSync(p)
13
+ } catch (e) {
14
+ return resolve(p)
15
+ }
16
+ }),
17
+ exclude: /node_modules/,
18
+ use: [
19
+ {
20
+ loader: 'babel-loader',
21
+ options: {
22
+ cacheDirectory: true,
23
+ cacheCompression: nodeEnv === 'production',
24
+ compact: nodeEnv === 'production'
25
+ }
26
+ }
27
+ ]
28
+ }
@@ -0,0 +1,3 @@
1
+ const getStyleRule = require('../utils/get_style_rule')
2
+
3
+ module.exports = getStyleRule(/\.(css)$/i)
@@ -0,0 +1,21 @@
1
+ const { join, normalize } = require('path')
2
+ const { source_path: sourcePath, static_assets_extensions: fileExtensions } = require('../config')
3
+
4
+ module.exports = {
5
+ test: new RegExp(`(${fileExtensions.join('|')})$`, 'i'),
6
+ use: [
7
+ {
8
+ loader: 'file-loader',
9
+ options: {
10
+ name(file) {
11
+ if (file.includes(normalize(sourcePath))) {
12
+ return 'media/[path][name]-[hash].[ext]'
13
+ }
14
+ return 'media/[folder]/[name]-[hash:8].[ext]'
15
+ },
16
+ esModule: false,
17
+ context: join(sourcePath)
18
+ }
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,20 @@
1
+ const babel = require('./babel')
2
+ const file = require('./file')
3
+ const css = require('./css')
4
+ const sass = require('./sass')
5
+ const moduleCss = require('./module.css')
6
+ const moduleSass = require('./module.sass')
7
+ const nodeModules = require('./node_modules')
8
+
9
+ // Webpack loaders are processed in reverse order
10
+ // https://webpack.js.org/concepts/loaders/#loader-features
11
+ // Lastly, process static files using file loader
12
+ module.exports = {
13
+ file,
14
+ css,
15
+ sass,
16
+ moduleCss,
17
+ moduleSass,
18
+ nodeModules,
19
+ babel
20
+ }
@@ -0,0 +1,3 @@
1
+ const getStyleRule = require('../utils/get_style_rule')
2
+
3
+ module.exports = getStyleRule(/\.(css)$/i, true)
@@ -0,0 +1,8 @@
1
+ const getStyleRule = require('../utils/get_style_rule')
2
+
3
+ module.exports = getStyleRule(/\.(scss|sass)$/i, true, [
4
+ {
5
+ loader: 'sass-loader',
6
+ options: { sourceMap: true }
7
+ }
8
+ ])
@@ -0,0 +1,22 @@
1
+ const { nodeEnv } = require('../env')
2
+
3
+ // Compile standard ES features for JS in node_modules with Babel.
4
+ // Regex details for exclude: https://regex101.com/r/SKPnnv/1
5
+ module.exports = {
6
+ test: /\.(js|mjs)$/,
7
+ include: /node_modules/,
8
+ exclude: /(?:@?babel(?:\/|\\{1,2}|-).+)|regenerator-runtime|core-js|^webpack$|^webpack-assets-manifest$|^webpack-cli$|^webpack-sources$|^@rails\/webpacker$/,
9
+ use: [
10
+ {
11
+ loader: 'babel-loader',
12
+ options: {
13
+ babelrc: false,
14
+ presets: [['@babel/preset-env', { modules: false }]],
15
+ cacheDirectory: true,
16
+ cacheCompression: nodeEnv === 'production',
17
+ compact: false,
18
+ sourceMaps: false
19
+ }
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,17 @@
1
+ /* eslint global-require: 0 */
2
+
3
+ const getStyleRule = require('../utils/get_style_rule')
4
+ const { additional_paths: includePaths } = require('../config')
5
+
6
+ module.exports = getStyleRule(/\.(scss|sass)(\.erb)?$/i, false, [
7
+ {
8
+ loader: 'sass-loader',
9
+ options: {
10
+ sourceMap: true,
11
+ implementation: require('sass'),
12
+ sassOptions: {
13
+ includePaths
14
+ }
15
+ }
16
+ }
17
+ ])
@@ -0,0 +1,32 @@
1
+ /* global test expect */
2
+
3
+ const deepAssign = require('../deep_assign')
4
+
5
+ describe('deepAssign()', () => {
6
+ test('deeply assigns nested properties', () => {
7
+ const object = { foo: { bar: { } } }
8
+ const path = 'foo.bar'
9
+ const value = { x: 1, y: 2 }
10
+ const expectation = { foo: { bar: { x: 1, y: 2 } } }
11
+ expect(deepAssign(object, path, value)).toEqual(expectation)
12
+ })
13
+
14
+ test('allows assignment of a literal false', () => {
15
+ const object = { foo: { bar: { } } }
16
+ const path = 'foo.bar'
17
+ const value = false
18
+ const expectation = { foo: { bar: false } }
19
+ expect(deepAssign(object, path, value)).toEqual(expectation)
20
+ })
21
+
22
+ test('does not allow assignment of other falsy values', () => {
23
+ const object = { foo: { bar: { } } }
24
+ const path = 'foo.bar'
25
+ const values = [undefined, null, 0, '']
26
+
27
+ values.forEach(value => {
28
+ const expectation = new Error(`Value can't be ${value}`)
29
+ expect(() => deepAssign(object, path, value)).toThrow(expectation)
30
+ })
31
+ })
32
+ })
@@ -0,0 +1,10 @@
1
+ /* global test expect */
2
+
3
+ const deepMerge = require('../deep_merge')
4
+
5
+ test('deep merge objects together', () => {
6
+ const object1 = { foo: { bar: [1, 2, 3], z: 1 }, x: 0 }
7
+ const object2 = { foo: { bar: ['x', 'y'] }, x: 1, y: 2 }
8
+ const expectation = { foo: { bar: [1, 2, 3, 'x', 'y'], z: 1 }, x: 1, y: 2 }
9
+ expect(deepMerge(object1, object2)).toEqual(expectation)
10
+ })
@@ -0,0 +1,65 @@
1
+ const { chdirTestApp, chdirCwd } = require('../helpers')
2
+
3
+ chdirTestApp()
4
+
5
+ const getStyleRule = require('../get_style_rule')
6
+
7
+ describe('getStyleRule', () => {
8
+ afterAll(chdirCwd)
9
+
10
+ test('excludes modules by default', () => {
11
+ const cssRule = getStyleRule(/\.(css)$/i)
12
+ const expectation = {
13
+ test: /\.(css)$/i,
14
+ exclude: /\.module\.[a-z]+$/
15
+ }
16
+
17
+ expect(cssRule).toMatchObject(expectation)
18
+ })
19
+
20
+ test('includes modules if set to true', () => {
21
+ const cssRule = getStyleRule(/\.(scss)$/i, true)
22
+ const expectation = {
23
+ test: /\.(scss)$/i,
24
+ include: /\.module\.[a-z]+$/
25
+ }
26
+
27
+ expect(cssRule).toMatchObject(expectation)
28
+ })
29
+
30
+ test('adds extra preprocessors if supplied', () => {
31
+ const expectation = [{ foo: 'bar' }]
32
+ const cssRule = getStyleRule(/\.(css)$/i, true, expectation)
33
+
34
+ expect(cssRule.use).toMatchObject(expect.arrayContaining(expectation))
35
+ })
36
+
37
+ test('adds mini-css-extract-plugin when extract_css is true', () => {
38
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
39
+ const expectation = [MiniCssExtractPlugin.loader]
40
+
41
+ require('../../config').extract_css = true
42
+ const cssRule = getStyleRule(/\.(css)$/i)
43
+
44
+ expect(cssRule.use).toMatchObject(expect.arrayContaining(expectation))
45
+ })
46
+
47
+ test('adds style-loader when extract_css is true', () => {
48
+ const expectation = [{loader: 'style-loader'}]
49
+
50
+ require('../../config').extract_css = false
51
+ const cssRule = getStyleRule(/\.(css)$/i)
52
+
53
+ expect(cssRule.use).toMatchObject(expect.objectContaining(expectation))
54
+ })
55
+
56
+ test(`doesn't add mini-css-extract-plugin when extract_css is false`, () => {
57
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
58
+ const expectation = [MiniCssExtractPlugin.loader]
59
+
60
+ require('../../config').extract_css = false
61
+ const cssRule = getStyleRule(/\.(css)$/i)
62
+
63
+ expect(cssRule.use).toMatchObject(expect.not.arrayContaining(expectation))
64
+ })
65
+ })
@@ -0,0 +1,9 @@
1
+ /* global test expect */
2
+
3
+ const objectify = require('../objectify')
4
+
5
+ test('Get object from a string path', () => {
6
+ const object = { foo: { bar: { x: 1 } } }
7
+ expect(objectify('foo.bar', object)).toEqual({ x: 1 })
8
+ expect(objectify('some.bar', object)).toEqual(undefined)
9
+ })
@@ -0,0 +1,22 @@
1
+ const { canMerge, prettyPrint } = require('./helpers')
2
+ const deepMerge = require('./deep_merge')
3
+
4
+ const deepAssign = (obj, path, value) => {
5
+ if (!value && value !== false) throw new Error(`Value can't be ${value}`)
6
+
7
+ const keys = path.split('.')
8
+ const key = keys.pop()
9
+
10
+ const objRef = keys.reduce((acc, currentValue) => {
11
+ /* eslint no-param-reassign: 0 */
12
+ if (!acc[currentValue]) acc[currentValue] = {}
13
+ return acc[currentValue]
14
+ }, obj)
15
+
16
+ if (!objRef) throw new Error(`Prop not found: ${path} in ${prettyPrint(obj)}`)
17
+
18
+ objRef[key] = canMerge(value) ? deepMerge(objRef[key], value) : value
19
+ return obj
20
+ }
21
+
22
+ module.exports = deepAssign
@@ -0,0 +1,22 @@
1
+ const {
2
+ isObject, isArray, isEqual, isEmpty
3
+ } = require('./helpers')
4
+
5
+ const deepMerge = (target, source) => {
6
+ if (isEmpty(target)) return source
7
+ if (isEmpty(source)) return target
8
+ if (isEqual(target, source)) return source
9
+ if (isArray(target) && isArray(source)) return [...new Set([...target, ...source])]
10
+ if (!(isObject(target) && isObject(source))) return source
11
+
12
+ return [...Object.keys(target), ...Object.keys(source)].reduce(
13
+ (result, key) => ({
14
+
15
+ ...result,
16
+ [key]: deepMerge(target[key], source[key])
17
+ }),
18
+ {}
19
+ )
20
+ }
21
+
22
+ module.exports = deepMerge
@@ -0,0 +1,45 @@
1
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
2
+ const { resolve } = require('path')
3
+ const config = require('../config')
4
+
5
+ const styleLoader = {
6
+ loader: 'style-loader'
7
+ }
8
+
9
+ const getStyleRule = (test, modules = false, preprocessors = []) => {
10
+ const use = [
11
+ {
12
+ loader: 'css-loader',
13
+ options: {
14
+ sourceMap: true,
15
+ importLoaders: 2,
16
+ modules: modules ? {
17
+ localIdentName: '[name]__[local]___[hash:base64:5]'
18
+ } : false
19
+ }
20
+ },
21
+ {
22
+ loader: 'postcss-loader',
23
+ options: {
24
+ config: { path: resolve() },
25
+ sourceMap: true
26
+ }
27
+ },
28
+ ...preprocessors
29
+ ]
30
+
31
+ const options = modules ? { include: /\.module\.[a-z]+$/ } : { exclude: /\.module\.[a-z]+$/ }
32
+
33
+ if (config.extract_css) {
34
+ use.unshift(MiniCssExtractPlugin.loader)
35
+ } else {
36
+ use.unshift(styleLoader)
37
+ }
38
+
39
+ // sideEffects - See https://github.com/webpack/webpack/issues/6571
40
+ return {
41
+ test, use, sideEffects: !modules, ...options
42
+ }
43
+ }
44
+
45
+ module.exports = getStyleRule