shakapacker 7.0.0.rc.1 → 7.0.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/README.md +2 -0
- data/lib/install/config/shakapacker.yml +9 -0
- data/lib/shakapacker/version.rb +1 -1
- data/package/__tests__/index-bc.js +22 -0
- data/package/environments/__tests__/base-bc.js +2 -2
- data/package/environments/__tests__/base.js +2 -2
- data/package/environments/__tests__/development.js +53 -0
- data/package/environments/__tests__/production.js +53 -0
- data/package/environments/base.js +4 -3
- data/package/environments/production.js +9 -0
- data/package/index.js +24 -17
- data/package.json +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58893ea0632011344e72e3fc4c887459f8e24872c5c5ab28792d1339d6d425e8
|
4
|
+
data.tar.gz: 2afede128c27cf45a4fcef08462fb9a64f5b89931075fdf89bd787af710939bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f49df282d8a4e42b28b2172a5f48b88d757c609323b57ffad3ab50091b3cea96110fcd5e6c9f865ab9552a7d49d51c864769ed0667c691f44f56d065b7d70ed
|
7
|
+
data.tar.gz: 1930a5cedaa8831fae4bbcab4e8baa05571414508ade9403e7b8a0ebd86f366d727ef6d3996e02a0a40e8b2faf21fdc5b4153a1fd7debd16e8467a8035071ee5
|
data/CHANGELOG.md
CHANGED
@@ -22,6 +22,7 @@ _Please add entries here for your pull requests that are not yet released._
|
|
22
22
|
- Set CSS modules mode depending on file type. [PR 261](https://github.com/shakacode/shakapacker/pull/261) by [talyuk](https://github.com/talyuk).
|
23
23
|
- All standard webpack entries with the camelCase format are now supported in `shakapacker.yml` in snake_case format. [PR276](https://github.com/shakacode/shakapacker/pull/276) by [ahangarha](https://github.com/ahangarha).
|
24
24
|
- The `shakapacker:install` rake task now has an option to force overriding files using `FORCE=true` environment variable [PR311](https://github.com/shakacode/shakapacker/pull/311) by [ahangarha](https://github.com/ahangarha).
|
25
|
+
- Allow configuration of use of contentHash for specific environment [PR 234](https://github.com/shakacode/shakapacker/pull/234) by [justin808](https://github/justin808).
|
25
26
|
|
26
27
|
### Changed
|
27
28
|
- Rename Webpacker to Shakapacker in the entire project including config files, binstubs, environment variables, etc. with a high degree of backward compatibility.
|
data/README.md
CHANGED
@@ -216,6 +216,8 @@ Webpack intelligently includes only necessary files. In this example, the file `
|
|
216
216
|
|
217
217
|
`nested_entries` allows you to have webpack entry points nested in subdirectories. This defaults to false so you don't accidentally create entry points for an entire tree of files. In other words, with `nested_entries: false`, you can have your entire `source_path` used for your source (using the `source_entry_path: /`) and you place files at the top level that you want as entry points. `nested_entries: true` allows you to have entries that are in subdirectories. This is useful if you have entries that are generated, so you can have a `generated` subdirectory and easily separate generated files from the rest of your codebase.
|
218
218
|
|
219
|
+
To enable/disable the usage of contentHash in any node environment (specified using the `NODE_ENV` environment variable), add/modify `useContentHash` with a boolean value in `config/shakapacker.yml`. This feature is disabled for all environments except production by default. You may not disable the content hash for a `NODE_ENV` of production as that would break the browser caching of assets. Notice that despite the possibility of enabling this option for the development environment, [it is not recommended](https://webpack.js.org/guides/build-performance/#avoid-production-specific-tooling).
|
220
|
+
|
219
221
|
#### Setting custom config path
|
220
222
|
|
221
223
|
You can use the environment variable `SHAKAPACKER_CONFIG` to enforce a particular path to the config file rather than the default `config/shakapacker.yml`.
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# Note: You must restart bin/shakapacker-dev-server for changes to take effect
|
2
|
+
# This file contains the defaults used by shakapacker.
|
2
3
|
|
3
4
|
default: &default
|
4
5
|
source_path: app/javascript
|
@@ -44,6 +45,11 @@ default: &default
|
|
44
45
|
# Select whether the compiler will use SHA digest ('digest' option) or most most recent modified timestamp ('mtime') to determine freshness
|
45
46
|
compiler_strategy: digest
|
46
47
|
|
48
|
+
# Select whether the compiler will always use a content hash and not just in production
|
49
|
+
# Don't use contentHash except for production for performance
|
50
|
+
# https://webpack.js.org/guides/build-performance/#avoid-production-specific-tooling
|
51
|
+
useContentHash: false
|
52
|
+
|
47
53
|
development:
|
48
54
|
<<: *default
|
49
55
|
compile: true
|
@@ -105,5 +111,8 @@ production:
|
|
105
111
|
# Production depends on precompilation of packs prior to booting for performance.
|
106
112
|
compile: false
|
107
113
|
|
114
|
+
# Use content hash for naming assets. Cannot be overridden by for production.
|
115
|
+
useContentHash: true
|
116
|
+
|
108
117
|
# Cache manifest.json for performance
|
109
118
|
cache_manifest: true
|
data/lib/shakapacker/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
const index = require('../index')
|
2
|
+
|
3
|
+
describe('index', () => {
|
4
|
+
describe('webpackConfig', () => {
|
5
|
+
test('is a global object', () => {
|
6
|
+
const { webpackConfig, globalMutableWebpackConfig } = require('../index')
|
7
|
+
|
8
|
+
expect(webpackConfig).toBe(globalMutableWebpackConfig)
|
9
|
+
})
|
10
|
+
|
11
|
+
test('Shows warning with deprecation message', () => {
|
12
|
+
const consoleSpy = jest.spyOn(console, "warn");
|
13
|
+
|
14
|
+
const { webpackConfig } = require('../index')
|
15
|
+
|
16
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
17
|
+
expect.stringMatching(/The 'webpackConfig' is deprecated/)
|
18
|
+
)
|
19
|
+
consoleSpy.mockRestore();
|
20
|
+
})
|
21
|
+
})
|
22
|
+
})
|
@@ -65,9 +65,9 @@ describe('Base config', () => {
|
|
65
65
|
})
|
66
66
|
|
67
67
|
test('should return output', () => {
|
68
|
-
expect(baseConfig.output.filename).toEqual('js/[name].js')
|
68
|
+
expect(baseConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
69
69
|
expect(baseConfig.output.chunkFilename).toEqual(
|
70
|
-
'js/[name].chunk.js'
|
70
|
+
'js/[name]-[contenthash].chunk.js'
|
71
71
|
)
|
72
72
|
})
|
73
73
|
|
@@ -65,9 +65,9 @@ describe('Base config', () => {
|
|
65
65
|
})
|
66
66
|
|
67
67
|
test('should return output', () => {
|
68
|
-
expect(baseConfig.output.filename).toEqual('js/[name].js')
|
68
|
+
expect(baseConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
69
69
|
expect(baseConfig.output.chunkFilename).toEqual(
|
70
|
-
'js/[name].chunk.js'
|
70
|
+
'js/[name]-[contenthash].chunk.js'
|
71
71
|
)
|
72
72
|
})
|
73
73
|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/* global test expect, describe, afterAll, beforeEach */
|
2
|
+
|
3
|
+
const { chdirTestApp, resetEnv } = require('../../utils/helpers')
|
4
|
+
const rootPath = process.cwd()
|
5
|
+
chdirTestApp()
|
6
|
+
|
7
|
+
describe('Development specific config', () => {
|
8
|
+
beforeEach(() => {
|
9
|
+
jest.resetModules()
|
10
|
+
resetEnv()
|
11
|
+
process.env['NODE_ENV'] = 'development'
|
12
|
+
})
|
13
|
+
afterAll(() => process.chdir(rootPath))
|
14
|
+
|
15
|
+
describe('with config.useContentHash = true', () => {
|
16
|
+
test('sets filename to use contentHash', () => {
|
17
|
+
const config = require("../../config");
|
18
|
+
config.useContentHash = true
|
19
|
+
const environmnetConfig = require('../development')
|
20
|
+
|
21
|
+
expect(environmnetConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
22
|
+
expect(environmnetConfig.output.chunkFilename).toEqual(
|
23
|
+
'js/[name]-[contenthash].chunk.js'
|
24
|
+
)
|
25
|
+
})
|
26
|
+
})
|
27
|
+
|
28
|
+
describe('with config.useContentHash = false', () => {
|
29
|
+
test('sets filename without using contentHash', () => {
|
30
|
+
const config = require("../../config");
|
31
|
+
config.useContentHash = false
|
32
|
+
const environmnetConfig = require('../development')
|
33
|
+
|
34
|
+
expect(environmnetConfig.output.filename).toEqual('js/[name].js')
|
35
|
+
expect(environmnetConfig.output.chunkFilename).toEqual(
|
36
|
+
'js/[name].chunk.js'
|
37
|
+
)
|
38
|
+
})
|
39
|
+
})
|
40
|
+
|
41
|
+
describe('with unset config.useContentHash', () => {
|
42
|
+
test('sets filename without using contentHash', () => {
|
43
|
+
const config = require("../../config");
|
44
|
+
delete config.useContentHash
|
45
|
+
const environmnetConfig = require('../development')
|
46
|
+
|
47
|
+
expect(environmnetConfig.output.filename).toEqual('js/[name].js')
|
48
|
+
expect(environmnetConfig.output.chunkFilename).toEqual(
|
49
|
+
'js/[name].chunk.js'
|
50
|
+
)
|
51
|
+
})
|
52
|
+
})
|
53
|
+
})
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/* global test expect, describe, afterAll, beforeEach */
|
2
|
+
|
3
|
+
const { chdirTestApp, resetEnv } = require('../../utils/helpers')
|
4
|
+
const rootPath = process.cwd()
|
5
|
+
chdirTestApp()
|
6
|
+
|
7
|
+
describe('Production specific config', () => {
|
8
|
+
beforeEach(() => {
|
9
|
+
jest.resetModules()
|
10
|
+
resetEnv()
|
11
|
+
process.env['NODE_ENV'] = 'production'
|
12
|
+
})
|
13
|
+
afterAll(() => process.chdir(rootPath))
|
14
|
+
|
15
|
+
describe('with config.useContentHash = true', () => {
|
16
|
+
test('sets filename to use contentHash', () => {
|
17
|
+
const config = require("../../config");
|
18
|
+
config.useContentHash = true
|
19
|
+
const environmnetConfig = require('../production')
|
20
|
+
|
21
|
+
expect(environmnetConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
22
|
+
expect(environmnetConfig.output.chunkFilename).toEqual(
|
23
|
+
'js/[name]-[contenthash].chunk.js'
|
24
|
+
)
|
25
|
+
})
|
26
|
+
})
|
27
|
+
|
28
|
+
describe('with config.useContentHash = false', () => {
|
29
|
+
test('sets filename to use contentHash', () => {
|
30
|
+
const config = require("../../config");
|
31
|
+
config.useContentHash = false
|
32
|
+
const environmnetConfig = require('../production')
|
33
|
+
|
34
|
+
expect(environmnetConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
35
|
+
expect(environmnetConfig.output.chunkFilename).toEqual(
|
36
|
+
'js/[name]-[contenthash].chunk.js'
|
37
|
+
)
|
38
|
+
})
|
39
|
+
})
|
40
|
+
|
41
|
+
describe('with unset config.useContentHash', () => {
|
42
|
+
test('sets filename to use contentHash', () => {
|
43
|
+
const config = require("../../config");
|
44
|
+
delete config.useContentHash
|
45
|
+
const environmnetConfig = require('../production')
|
46
|
+
|
47
|
+
expect(environmnetConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
48
|
+
expect(environmnetConfig.output.chunkFilename).toEqual(
|
49
|
+
'js/[name]-[contenthash].chunk.js'
|
50
|
+
)
|
51
|
+
})
|
52
|
+
})
|
53
|
+
})
|
@@ -7,8 +7,8 @@ const { sync: globSync } = require('glob')
|
|
7
7
|
const WebpackAssetsManifest = require('webpack-assets-manifest')
|
8
8
|
const webpack = require('webpack')
|
9
9
|
const rules = require('../rules')
|
10
|
-
const { isProduction } = require('../env')
|
11
10
|
const config = require('../config')
|
11
|
+
const { isProduction } = require('../env')
|
12
12
|
const { moduleExists } = require('../utils/helpers')
|
13
13
|
|
14
14
|
const getEntryObject = () => {
|
@@ -68,7 +68,7 @@ const getPlugins = () => {
|
|
68
68
|
]
|
69
69
|
|
70
70
|
if (moduleExists('css-loader') && moduleExists('mini-css-extract-plugin')) {
|
71
|
-
const hash = isProduction ? '-[contenthash:8]' : ''
|
71
|
+
const hash = isProduction || config.useContentHash ? '-[contenthash:8]' : ''
|
72
72
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
73
73
|
plugins.push(
|
74
74
|
new MiniCssExtractPlugin({
|
@@ -87,7 +87,8 @@ const getPlugins = () => {
|
|
87
87
|
|
88
88
|
// Don't use contentHash except for production for performance
|
89
89
|
// https://webpack.js.org/guides/build-performance/#avoid-production-specific-tooling
|
90
|
-
const hash = isProduction ? '-[contenthash]' : ''
|
90
|
+
const hash = isProduction || config.useContentHash ? '-[contenthash]' : ''
|
91
|
+
|
91
92
|
module.exports = {
|
92
93
|
mode: 'production',
|
93
94
|
output: {
|
@@ -6,6 +6,7 @@ const CompressionPlugin = require('compression-webpack-plugin')
|
|
6
6
|
const TerserPlugin = require('terser-webpack-plugin')
|
7
7
|
const baseConfig = require('./base')
|
8
8
|
const { moduleExists } = require('../utils/helpers')
|
9
|
+
const config = require('../config')
|
9
10
|
|
10
11
|
const getPlugins = () => {
|
11
12
|
const plugins = []
|
@@ -76,4 +77,12 @@ const productionConfig = {
|
|
76
77
|
}
|
77
78
|
}
|
78
79
|
|
80
|
+
if (config.useContentHash === true) {
|
81
|
+
// eslint-disable-next-line no-console
|
82
|
+
console.warn(`⚠️ WARNING
|
83
|
+
Setting 'useContentHash' to 'false' in the production environment (specified by NODE_ENV environment variable) is not allowed!
|
84
|
+
Content hashes get added to the filenames regardless of setting useContentHash in 'shakapacker.yml' to false.
|
85
|
+
`)
|
86
|
+
}
|
87
|
+
|
79
88
|
module.exports = merge(baseConfig, productionConfig)
|
data/package/index.js
CHANGED
@@ -25,27 +25,11 @@ const generateWebpackConfig = () => {
|
|
25
25
|
return immutable
|
26
26
|
}
|
27
27
|
|
28
|
-
const
|
29
|
-
// eslint-disable-next-line no-console
|
30
|
-
console.log(`⚠️
|
31
|
-
DEPRECATION NOTICE:
|
32
|
-
The 'webpackConfig' is deprecated and will be removed in a future version.
|
33
|
-
Please use 'globalMutableWebpackConfig' instead, or use
|
34
|
-
'generateWebpackConfig()' to avoid unwanted config manipulation across the app.
|
35
|
-
|
36
|
-
For more information, see version 7 upgrade documentation at:
|
37
|
-
https://github.com/shakacode/shakapacker/blob/master/docs/v7_upgrade.md
|
38
|
-
`)
|
39
|
-
|
40
|
-
return globalMutableWebpackConfig()
|
41
|
-
}
|
42
|
-
|
43
|
-
module.exports = {
|
28
|
+
const shakapackerObject = {
|
44
29
|
config, // shakapacker.yml
|
45
30
|
devServer,
|
46
31
|
generateWebpackConfig,
|
47
32
|
globalMutableWebpackConfig: globalMutableWebpackConfig(),
|
48
|
-
webpackConfig: webpackConfigForBackwardCompatibility(),
|
49
33
|
baseConfig,
|
50
34
|
env,
|
51
35
|
rules,
|
@@ -54,3 +38,26 @@ module.exports = {
|
|
54
38
|
inliningCss,
|
55
39
|
...webpackMerge
|
56
40
|
}
|
41
|
+
|
42
|
+
// For backward compatibility
|
43
|
+
const shakapackerProxyHandler = {
|
44
|
+
get(target, prop) {
|
45
|
+
if (prop === 'webpackConfig') {
|
46
|
+
// eslint-disable-next-line no-console
|
47
|
+
console.warn(`⚠️
|
48
|
+
DEPRECATION NOTICE:
|
49
|
+
The 'webpackConfig' is deprecated and will be removed in a future version.
|
50
|
+
Please use 'globalMutableWebpackConfig' instead, or use
|
51
|
+
'generateWebpackConfig()' to avoid unwanted config mutation across the app.
|
52
|
+
|
53
|
+
For more information, see version 7 upgrade documentation at:
|
54
|
+
https://github.com/shakacode/shakapacker/blob/master/docs/v7_upgrade.md
|
55
|
+
`)
|
56
|
+
return globalMutableWebpackConfig()
|
57
|
+
}
|
58
|
+
|
59
|
+
return target[prop]
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
module.exports = new Proxy(shakapackerObject, shakapackerProxyHandler)
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shakapacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.0.rc.
|
4
|
+
version: 7.0.0.rc.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-06-
|
13
|
+
date: 2023-06-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -230,6 +230,7 @@ files:
|
|
230
230
|
- package/__tests__/development.js
|
231
231
|
- package/__tests__/env-bc.js
|
232
232
|
- package/__tests__/env.js
|
233
|
+
- package/__tests__/index-bc.js
|
233
234
|
- package/__tests__/index.js
|
234
235
|
- package/__tests__/production-bc.js
|
235
236
|
- package/__tests__/production.js
|
@@ -243,6 +244,8 @@ files:
|
|
243
244
|
- package/env.js
|
244
245
|
- package/environments/__tests__/base-bc.js
|
245
246
|
- package/environments/__tests__/base.js
|
247
|
+
- package/environments/__tests__/development.js
|
248
|
+
- package/environments/__tests__/production.js
|
246
249
|
- package/environments/base.js
|
247
250
|
- package/environments/development.js
|
248
251
|
- package/environments/production.js
|
@@ -525,7 +528,7 @@ homepage: https://github.com/shakacode/shakapacker
|
|
525
528
|
licenses:
|
526
529
|
- MIT
|
527
530
|
metadata:
|
528
|
-
source_code_uri: https://github.com/shakacode/shakapacker/tree/v7.0.0-rc.
|
531
|
+
source_code_uri: https://github.com/shakacode/shakapacker/tree/v7.0.0-rc.2
|
529
532
|
post_install_message:
|
530
533
|
rdoc_options: []
|
531
534
|
require_paths:
|