@financial-times/dotcom-build-sass 7.3.0 → 7.3.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/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
2
  "name": "@financial-times/dotcom-build-sass",
3
- "version": "7.3.0",
3
+ "version": "7.3.1",
4
4
  "description": "",
5
5
  "main": "dist/node/index.js",
6
6
  "types": "src/index.ts",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1",
9
- "tsc": "../../node_modules/.bin/tsc --incremental",
10
9
  "clean": "npm run clean:dist && npm run clean:node_modules",
11
10
  "clean:dist": "rm -rf dist",
12
11
  "clean:node_modules": "rm -rf node_modules",
12
+ "build:node": "tsc",
13
13
  "build": "npm run build:node",
14
- "build:node": "npm run tsc -- --module commonjs --outDir ./dist/node",
15
14
  "dev": "npm run build:node -- --watch",
16
15
  "preinstall": "[ \"$INIT_CWD\" != \"$PWD\" ] || npm_config_yes=true npx check-engine"
17
16
  },
@@ -40,6 +39,9 @@
40
39
  "node": ">= 14.0.0",
41
40
  "npm": "7.x || 8.x"
42
41
  },
42
+ "files": [
43
+ "dist/"
44
+ ],
43
45
  "repository": {
44
46
  "type": "git",
45
47
  "repository": "https://github.com/Financial-Times/dotcom-page-kit.git",
@@ -49,4 +51,4 @@
49
51
  "volta": {
50
52
  "extends": "../../package.json"
51
53
  }
52
- }
54
+ }
package/src/index.ts DELETED
@@ -1,127 +0,0 @@
1
- import StylesOnlyPlugin from 'webpack-fix-style-only-entries'
2
- import MiniCssExtractPlugin from 'mini-css-extract-plugin'
3
- import type webpack from 'webpack'
4
-
5
- export type TPluginOptions = {
6
- includePaths?: string[]
7
- prependData?: string
8
- webpackImporter?: boolean
9
- }
10
-
11
- export class PageKitSassPlugin {
12
- includePaths: string[]
13
- prependData: string
14
- webpackImporter: boolean
15
-
16
- constructor({ includePaths = [], prependData = '', webpackImporter }: TPluginOptions = {}) {
17
- this.includePaths = includePaths
18
- this.prependData = prependData
19
- this.webpackImporter = webpackImporter
20
- }
21
-
22
- apply(compiler: webpack.Compiler) {
23
- const sassLoaderOptions = {
24
- // This enables the use of enhanced-resolve for @import statements prefixed with ~
25
- // but we don't usually use this and disabling it can speed up builds by up to 20%.
26
- webpackImporter: this.webpackImporter,
27
- // Prefer `dart-sass`.
28
- implementation: require('sass'),
29
- // Prepends SCSS code before the actual entry file.
30
- // Introduced to maintain snappy grid after n-ui-foundations removed it as the default.
31
- // Once user-facing apps and components move away from using snappy grid then this can be removed.
32
- prependData: this.prependData,
33
- sassOptions: {
34
- // Disable formatting so that we don't spend time pretty printing
35
- outputStyle: 'compressed',
36
- // Enable Sass to @import source files from installed dependencies
37
- includePaths: ['bower_components', 'node_modules', ...this.includePaths]
38
- }
39
- }
40
-
41
- const autoprefixerOptions = {
42
- // https://github.com/browserslist/browserslist
43
- overrideBrowserslist: ['last 1 Chrome versions', 'Safari >= 13', 'ff ESR', 'last 1 Edge versions'],
44
- grid: true
45
- }
46
-
47
- // https://cssnano.co/guides/optimisations
48
- const cssnanoOptions = {
49
- preset: [
50
- 'default',
51
- {
52
- // disable reduceInitial optimisation as `initial` is not supported in IE11
53
- // https://github.com/cssnano/cssnano/issues/721
54
- // https://developer.mozilla.org/en-US/docs/Web/CSS/initial
55
- reduceInitial: false
56
- }
57
- ]
58
- }
59
-
60
- const postcssLoaderOptions = {
61
- postcssOptions: {
62
- plugins: [
63
- // Add vendor prefixes automatically using data from Can I Use
64
- // https://github.com/postcss/autoprefixer
65
- require('autoprefixer')(autoprefixerOptions),
66
- // Ensure that the final result is as small as possible. This can
67
- // de-duplicate rule-sets which is useful if $o-silent-mode is toggled.
68
- // https://github.com/cssnano/cssnano
69
- require('cssnano')(cssnanoOptions)
70
- ]
71
- },
72
- implementation: require('postcss')
73
- }
74
-
75
- const cssLoaderOptions = {
76
- // Allow css-loader to resolve @import because the sass-loader
77
- // does not successfully resolve files with a .css extension.
78
- import: true,
79
- // Disable Webpack from resolving url() because we do not
80
- // currently use this functionality.
81
- url: false
82
- }
83
-
84
- const miniCssExtractPluginOptions = {
85
- // only include content hash in filename when compiling production assets
86
- filename: compiler.options.mode === 'development' ? '[name].css' : '[name].[contenthash:12].css'
87
- }
88
-
89
- // This plugin prevents empty JS bundles being created for CSS entry points
90
- // https://github.com/fqborges/webpack-fix-style-only-entries
91
- const stylesOnlyPluginOptions = {
92
- silent: true
93
- }
94
-
95
- compiler.options.module.rules.push({
96
- test: [/\.sass|scss$/],
97
- use: [
98
- // Extracts CSS into separate, non-JS files
99
- // https://github.com/webpack-contrib/mini-css-extract-plugin
100
- {
101
- loader: MiniCssExtractPlugin.loader
102
- },
103
- // Add support for handling .css files
104
- // https://github.com/webpack-contrib/css-loader
105
- {
106
- loader: require.resolve('css-loader'),
107
- options: cssLoaderOptions
108
- },
109
- // Enable use of PostCSS for CSS postprocessing
110
- // https://github.com/postcss/postcss-loader
111
- {
112
- loader: require.resolve('postcss-loader'),
113
- options: postcssLoaderOptions
114
- },
115
- // Enable use of Sass for CSS preprocessing
116
- // https://github.com/webpack-contrib/sass-loader
117
- {
118
- loader: require.resolve('sass-loader'),
119
- options: sassLoaderOptions
120
- }
121
- ]
122
- })
123
-
124
- new StylesOnlyPlugin(stylesOnlyPluginOptions).apply(compiler)
125
- new MiniCssExtractPlugin(miniCssExtractPluginOptions).apply(compiler)
126
- }
127
- }