@financial-times/dotcom-build-sass 11.3.0 → 12.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.
- package/README.md +0 -4
- package/dist/node/index.d.ts +2 -4
- package/dist/node/index.js +18 -36
- package/dist/node/monitored-sass-loader.js +47 -48
- package/dist/tsconfig.tsbuildinfo +1 -2823
- package/package.json +9 -14
- package/src/index.ts +17 -41
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@financial-times/dotcom-build-sass",
|
3
|
-
"version": "
|
3
|
+
"version": "12.0.1",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/node/index.js",
|
6
6
|
"types": "dist/node/index.d.ts",
|
@@ -17,23 +17,18 @@
|
|
17
17
|
"author": "",
|
18
18
|
"license": "MIT",
|
19
19
|
"peerDependencies": {
|
20
|
-
"webpack": "
|
20
|
+
"webpack": "5.x"
|
21
21
|
},
|
22
22
|
"dependencies": {
|
23
|
-
"
|
24
|
-
"css-
|
25
|
-
"
|
26
|
-
"mini-css-extract-plugin": "^0.12.0",
|
23
|
+
"css-loader": "^6.8.1",
|
24
|
+
"css-minimizer-webpack-plugin": "^7.0.0",
|
25
|
+
"mini-css-extract-plugin": "^2.9.1",
|
27
26
|
"postcss": "^8.4.20",
|
28
27
|
"postcss-import": "^16.1.0",
|
29
|
-
"postcss-loader": "^
|
30
|
-
"sass": "^1.
|
31
|
-
"sass-
|
32
|
-
"
|
33
|
-
"webpack-fix-style-only-entries": "^0.5.0"
|
34
|
-
},
|
35
|
-
"devDependencies": {
|
36
|
-
"@types/webpack": "^4.41.7"
|
28
|
+
"postcss-loader": "^7.3.3",
|
29
|
+
"sass-embedded": "^1.67.0",
|
30
|
+
"sass-loader": "^13.3.2",
|
31
|
+
"webpack-remove-empty-scripts": "^1.0.4"
|
37
32
|
},
|
38
33
|
"engines": {
|
39
34
|
"node": "18.x || 20.x || 22.x"
|
package/src/index.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
import StylesOnlyPlugin from 'webpack-fix-style-only-entries'
|
2
1
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
2
|
+
import RemoveEmptyScriptsPlugin from 'webpack-remove-empty-scripts'
|
3
|
+
import CSSMinimizerPlugin from 'css-minimizer-webpack-plugin'
|
3
4
|
import type webpack from 'webpack'
|
4
5
|
|
5
6
|
export type TPluginOptions = {
|
6
7
|
includePaths?: string[]
|
7
|
-
prependData?: string // DEPRECATED IN FAVOUR OF additionalData
|
8
8
|
additionalData?: string
|
9
9
|
webpackImporter?: boolean
|
10
10
|
implementation?: 'sass' | 'sass-embedded'
|
@@ -12,20 +12,18 @@ export type TPluginOptions = {
|
|
12
12
|
|
13
13
|
export class PageKitSassPlugin {
|
14
14
|
includePaths: string[]
|
15
|
-
prependData: string // DEPRECATED IN FAVOUR OF additionalData
|
16
15
|
additionalData: string
|
17
16
|
webpackImporter: boolean
|
18
17
|
implementation: 'sass' | 'sass-embedded'
|
19
18
|
|
20
19
|
constructor({
|
21
20
|
includePaths = [],
|
22
|
-
prependData = '',
|
23
21
|
additionalData = '',
|
24
22
|
webpackImporter,
|
25
23
|
implementation = 'sass'
|
26
24
|
}: TPluginOptions = {}) {
|
27
25
|
this.includePaths = includePaths
|
28
|
-
this.additionalData = additionalData
|
26
|
+
this.additionalData = additionalData
|
29
27
|
this.webpackImporter = webpackImporter
|
30
28
|
this.implementation = implementation
|
31
29
|
}
|
@@ -45,42 +43,16 @@ export class PageKitSassPlugin {
|
|
45
43
|
// Disable formatting so that we don't spend time pretty printing
|
46
44
|
outputStyle: 'compressed',
|
47
45
|
// Enable Sass to @import source files from installed dependencies
|
48
|
-
includePaths: ['
|
46
|
+
includePaths: ['node_modules/@financial-times', 'node_modules', ...this.includePaths]
|
49
47
|
}
|
50
48
|
}
|
51
49
|
|
52
|
-
const autoprefixerOptions = {
|
53
|
-
// https://github.com/browserslist/browserslist
|
54
|
-
overrideBrowserslist: ['last 1 Chrome versions', 'Safari >= 13', 'ff ESR', 'last 1 Edge versions'],
|
55
|
-
grid: true
|
56
|
-
}
|
57
|
-
|
58
|
-
// https://cssnano.co/guides/optimisations
|
59
|
-
const cssnanoOptions = {
|
60
|
-
preset: [
|
61
|
-
'default',
|
62
|
-
{
|
63
|
-
// disable reduceInitial optimisation as `initial` is not supported in IE11
|
64
|
-
// https://github.com/cssnano/cssnano/issues/721
|
65
|
-
// https://developer.mozilla.org/en-US/docs/Web/CSS/initial
|
66
|
-
reduceInitial: false
|
67
|
-
}
|
68
|
-
]
|
69
|
-
}
|
70
|
-
|
71
50
|
const postcssLoaderOptions = {
|
72
51
|
postcssOptions: {
|
73
52
|
plugins: [
|
74
53
|
// Allow @import of CSS files from node_modules
|
75
54
|
// https://github.com/postcss/postcss-import
|
76
|
-
require('postcss-import')()
|
77
|
-
// Add vendor prefixes automatically using data from Can I Use
|
78
|
-
// https://github.com/postcss/autoprefixer
|
79
|
-
require('autoprefixer')(autoprefixerOptions),
|
80
|
-
// Ensure that the final result is as small as possible. This can
|
81
|
-
// de-duplicate rule-sets which is useful if $o-silent-mode is toggled.
|
82
|
-
// https://github.com/cssnano/cssnano
|
83
|
-
require('cssnano')(cssnanoOptions)
|
55
|
+
require('postcss-import')()
|
84
56
|
]
|
85
57
|
},
|
86
58
|
implementation: require('postcss')
|
@@ -100,13 +72,9 @@ export class PageKitSassPlugin {
|
|
100
72
|
|
101
73
|
const miniCssExtractPluginOptions = {
|
102
74
|
// only include content hash in filename when compiling production assets
|
103
|
-
filename: compiler.options.mode === 'development' ? '[name].css' : '[name].[contenthash:12].css'
|
104
|
-
|
105
|
-
|
106
|
-
// This plugin prevents empty JS bundles being created for CSS entry points
|
107
|
-
// https://github.com/fqborges/webpack-fix-style-only-entries
|
108
|
-
const stylesOnlyPluginOptions = {
|
109
|
-
silent: true
|
75
|
+
filename: compiler.options.mode === 'development' ? '[name].css' : '[name].[contenthash:12].css',
|
76
|
+
// we load CSS files ourselves in `dotcom-ui-shell` so don't need the runtime
|
77
|
+
runtime: false
|
110
78
|
}
|
111
79
|
|
112
80
|
compiler.options.module.rules.push({
|
@@ -138,7 +106,15 @@ export class PageKitSassPlugin {
|
|
138
106
|
]
|
139
107
|
})
|
140
108
|
|
141
|
-
|
109
|
+
compiler.options.optimization.minimizer = [
|
110
|
+
...(compiler.options.optimization.minimizer ?? []),
|
111
|
+
new CSSMinimizerPlugin()
|
112
|
+
]
|
113
|
+
|
114
|
+
// 2024 and this is still an issue :/ mini-css-extract-plugin leaves
|
115
|
+
// behind empty .js bundles after extracting the CSS.
|
116
|
+
// https://github.com/webpack/webpack/issues/11671
|
117
|
+
new RemoveEmptyScriptsPlugin().apply(compiler)
|
142
118
|
new MiniCssExtractPlugin(miniCssExtractPluginOptions).apply(compiler)
|
143
119
|
}
|
144
120
|
}
|