webpacker 6.0.0.beta.1 → 6.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6443ddc11bf717fe1987306bc46527edf1692dfdc8bb3b827a8918a5e81b89b
4
- data.tar.gz: 9dd83b7b25ee965abe951b86e3529797ef8f51e7dd5e3b94011f4d781adfab8c
3
+ metadata.gz: 70198a585cf22360094497e860a23dcd172c7926820eaa905b00eaf15c997010
4
+ data.tar.gz: a1ff9f0cc031d1fffc69813b071b10947aa1648fbedaee826be547bd03adcdc2
5
5
  SHA512:
6
- metadata.gz: 64209399bfb645bb325799c6f4267e78439d59481983a5906888203cdec03034bb592dc226d93da70f56b5567337a4cf91352a85d1dfc0e386fdceea8ef1ecb9
7
- data.tar.gz: 296d7238ffb6ad997ed71730304aeb34330610ccd2ec4f0838d3fbbec0bf4d39a0131b1f3fc2a9779c0a51e161f4a7952974ee04b47ca7edab9a6f2a9a5aa651
6
+ metadata.gz: 2e16cfe7311345f9e2af7e4b821ada9acdaff357ff64cbbbebf038a43199dcafa3b82c403bec1f9ab182ff456efd9ff14eb9756b4edbd76c68beba3cf8543cdc
7
+ data.tar.gz: de893725da86a372346c6c552a49a4efb078e24343e16a173b6d51230dc2ccb8bc26d5fbf8726d6d8f8d1a7277eea81d3ed29a06c76998db98cb5970c040bcb0
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webpacker (6.0.0.beta.1)
4
+ webpacker (6.0.0.beta.2)
5
5
  activesupport (>= 5.2)
6
6
  rack-proxy (>= 0.6.1)
7
7
  railties (>= 5.2)
data/README.md CHANGED
@@ -334,13 +334,19 @@ yarn add postcss-loader
334
334
  #### Sass
335
335
 
336
336
  ```
337
- yarn add sass-loader
337
+ yarn add sass sass-loader
338
338
  ```
339
339
 
340
340
  #### Less
341
341
 
342
342
  ```
343
- yarn add less-loader
343
+ yarn add less less-loader
344
+ ```
345
+
346
+ #### Less
347
+
348
+ ```
349
+ yarn add stylus stylus-loader
344
350
  ```
345
351
 
346
352
  #### React
@@ -1,4 +1,4 @@
1
1
  module Webpacker
2
2
  # Change the version in package.json too, please!
3
- VERSION = "6.0.0.beta.1".freeze
3
+ VERSION = "6.0.0.beta.2".freeze
4
4
  end
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rails/webpacker",
3
- "version": "6.0.0-beta.1",
3
+ "version": "6.0.0-beta.2",
4
4
  "description": "Use webpack to manage app-like JavaScript modules in Rails",
5
5
  "main": "package/index.js",
6
6
  "files": [
@@ -39,8 +39,8 @@ describe('Base config', () => {
39
39
  const defaultRules = Object.keys(rules)
40
40
  const configRules = baseConfig.module.rules
41
41
 
42
- expect(defaultRules.length).toEqual(4)
43
- expect(configRules.length).toEqual(4)
42
+ expect(defaultRules.length).toEqual(3)
43
+ expect(configRules.length).toEqual(3)
44
44
  })
45
45
 
46
46
  test('should return default plugins', () => {
@@ -67,8 +67,12 @@ const getPlugins = () => {
67
67
  const MiniCssExtractPlugin = require('mini-css-extract-plugin')
68
68
  plugins.push(
69
69
  new MiniCssExtractPlugin({
70
- filename: isDevelopment ? '[name].css' : '[name].[contenthash:8].css',
71
- chunkFilename: isDevelopment ? '[id].css' : '[id].[contenthash:8].css'
70
+ filename: isDevelopment
71
+ ? 'css/[name].css'
72
+ : 'css/[name]-[contenthash:8].css',
73
+ chunkFilename: isDevelopment
74
+ ? 'css/[id].css'
75
+ : 'css/[id]-[contenthash:8].css'
72
76
  })
73
77
  )
74
78
  }
@@ -82,7 +86,6 @@ module.exports = {
82
86
  filename: 'js/[name]-[contenthash].js',
83
87
  chunkFilename: 'js/[name]-[contenthash].chunk.js',
84
88
  hotUpdateChunkFilename: 'js/[id]-[hash].hot-update.js',
85
- assetModuleFilename: 'static/[hash][ext][query]',
86
89
  path: config.outputPath,
87
90
  publicPath: config.publicPath
88
91
  },
@@ -8,21 +8,39 @@ const baseConfig = require('./base')
8
8
  const { moduleExists } = require('../utils/helpers')
9
9
 
10
10
  const getPlugins = () => {
11
- let compressionPlugin = new CompressionPlugin({
12
- filename: '[path].gz[query]',
13
- algorithm: 'gzip',
14
- test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/
15
- })
11
+ const plugins = []
16
12
 
17
- if ('brotli' in process.versions) {
18
- compressionPlugin = new CompressionPlugin({
19
- filename: '[path].br[query]',
20
- algorithm: 'brotliCompress',
13
+ plugins.push(
14
+ new CompressionPlugin({
15
+ filename: '[path][base].gz[query]',
16
+ algorithm: 'gzip',
21
17
  test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/
22
18
  })
19
+ )
20
+
21
+ if ('brotli' in process.versions) {
22
+ plugins.push(
23
+ new CompressionPlugin({
24
+ filename: '[path][base].br[query]',
25
+ algorithm: 'brotliCompress',
26
+ test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/
27
+ })
28
+ )
23
29
  }
24
30
 
25
- return [compressionPlugin]
31
+ return plugins
32
+ }
33
+
34
+ const tryCssMinimizer = () => {
35
+ if (
36
+ moduleExists('css-loader') &&
37
+ moduleExists('css-minimizer-webpack-plugin')
38
+ ) {
39
+ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
40
+ return new CssMinimizerPlugin({ sourceMap: true })
41
+ }
42
+
43
+ return null
26
44
  }
27
45
 
28
46
  const productionConfig = {
@@ -32,18 +50,7 @@ const productionConfig = {
32
50
  plugins: getPlugins(),
33
51
  optimization: {
34
52
  minimizer: [
35
- () => {
36
- if (
37
- moduleExists('css-loader') &&
38
- moduleExists('css-minimizer-webpack-plugin')
39
- ) {
40
- const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
41
- return new CssMinimizerPlugin({ sourceMap: true })
42
- }
43
-
44
- return false
45
- },
46
-
53
+ tryCssMinimizer(),
47
54
  new TerserPlugin({
48
55
  parallel: Number.parseInt(process.env.WEBPACKER_PARALLEL, 10) || true,
49
56
  terserOptions: {
@@ -12,8 +12,12 @@ module.exports = {
12
12
  /\.otf$/,
13
13
  /\.ttf$/,
14
14
  /\.woff$/,
15
- /\.woff2$/
15
+ /\.woff2$/,
16
+ /\.svg$/
16
17
  ],
17
18
  exclude: [/\.(js|mjs|jsx|ts|tsx)$/],
18
- type: 'asset/resource'
19
+ type: 'asset/resource',
20
+ generator: {
21
+ filename: 'media/images/[hash][ext][query]'
22
+ }
19
23
  }
@@ -2,15 +2,15 @@
2
2
  /* eslint import/no-dynamic-require: 0 */
3
3
 
4
4
  const rules = {
5
+ raw: require('./raw'),
5
6
  file: require('./file'),
6
- svg: require('./svg'),
7
7
  css: require('./css'),
8
8
  sass: require('./sass'),
9
9
  babel: require('./babel'),
10
10
  erb: require('./erb'),
11
11
  coffee: require('./coffee'),
12
12
  less: require('./less'),
13
- raw: require('./raw')
13
+ stylus: require('./stylus')
14
14
  }
15
15
 
16
16
  module.exports = Object.keys(rules)
@@ -0,0 +1,26 @@
1
+ const path = require('path')
2
+ const { canProcess } = require('../utils/helpers')
3
+ const getStyleRule = require('../utils/get_style_rule')
4
+
5
+ const {
6
+ additional_paths: paths,
7
+ source_path: sourcePath
8
+ } = require('../config')
9
+
10
+ module.exports = canProcess('stylus-loader', (resolvedPath) =>
11
+ getStyleRule(/\.(styl)(\.erb)?$/i, [
12
+ {
13
+ loader: resolvedPath,
14
+ options: {
15
+ stylusOptions: {
16
+ include: [
17
+ path.resolve(__dirname, 'node_modules'),
18
+ sourcePath,
19
+ ...paths
20
+ ]
21
+ },
22
+ sourceMap: true
23
+ }
24
+ }
25
+ ])
26
+ )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpacker
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.beta.1
4
+ version: 6.0.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-12-23 00:00:00.000000000 Z
12
+ date: 2020-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -203,7 +203,7 @@ files:
203
203
  - package/rules/less.js
204
204
  - package/rules/raw.js
205
205
  - package/rules/sass.js
206
- - package/rules/svg.js
206
+ - package/rules/stylus.js
207
207
  - package/utils/get_style_rule.js
208
208
  - package/utils/helpers.js
209
209
  - test/command_test.rb
@@ -250,8 +250,8 @@ homepage: https://github.com/rails/webpacker
250
250
  licenses:
251
251
  - MIT
252
252
  metadata:
253
- source_code_uri: https://github.com/rails/webpacker/tree/v6.0.0.beta.1
254
- changelog_uri: https://github.com/rails/webpacker/blob/v6.0.0.beta.1/CHANGELOG.md
253
+ source_code_uri: https://github.com/rails/webpacker/tree/v6.0.0.beta.2
254
+ changelog_uri: https://github.com/rails/webpacker/blob/v6.0.0.beta.2/CHANGELOG.md
255
255
  post_install_message:
256
256
  rdoc_options: []
257
257
  require_paths:
@@ -1,20 +0,0 @@
1
- /* eslint global-require: 0 */
2
- /* eslint import/no-dynamic-require: 0 */
3
- const { moduleExists } = require('../utils/helpers')
4
-
5
- module.exports = {
6
- test: /\.svg$/i,
7
- type: 'asset/inline',
8
- generator: {
9
- dataUrl: (content) => {
10
- let optimisedContent = content
11
-
12
- if (moduleExists('mini-svg-data-uri')) {
13
- const svgToMiniDataURI = require('mini-svg-data-uri')
14
- optimisedContent = svgToMiniDataURI(content.toString())
15
- }
16
-
17
- return optimisedContent
18
- }
19
- }
20
- }