@epublishing/grunt-epublishing 0.3.1 → 0.3.3

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.
@@ -4,20 +4,13 @@
4
4
 
5
5
  'use strict';
6
6
 
7
- const _ = require('lodash');
8
- const sass = require('node-sass');
7
+ const sass = require('sass');
9
8
  const NODE_ENV = process.env.NODE_ENV || 'development';
10
9
 
11
10
  module.exports = function configureSass(config) {
12
11
 
13
12
  config.sass.options.functions = {
14
- 'epub-show-deprecation-warnings()': () => {
15
- if (_.includes([ 'local', 'development' ], NODE_ENV)) {
16
- return sass.types.Boolean.TRUE;
17
- }
18
- return sass.types.Boolean.FALSE;
19
- },
20
- 'epub-node-env()': () => new sass.types.String(NODE_ENV),
13
+ 'epub-node-env()': () => new sass.String(NODE_ENV),
21
14
  };
22
15
 
23
16
  return config;
@@ -3,25 +3,26 @@
3
3
  * targets, including loaders and output plugins.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const os = require('os');
9
- const fs = require('fs');
10
- const path = require('path');
11
- const webpack = require('webpack');
12
- const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
13
- const CompressionPlugin = require('compression-webpack-plugin');
14
- const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
15
- const lodashDir = path.dirname(require.resolve('lodash'));
16
- const moduleDir = path.dirname(lodashDir);
6
+ "use strict";
7
+
8
+ const os = require("os");
9
+ const fs = require("fs");
10
+ const path = require("path");
11
+ const webpack = require("webpack");
12
+ const BundleAnalyzerPlugin =
13
+ require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
14
+ const CompressionPlugin = require("compression-webpack-plugin");
15
+ const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
16
+ const lodashDir = path.dirname(require.resolve("lodash"));
17
+ const moduleDir = path.dirname(lodashDir);
17
18
 
18
19
  module.exports = function configureWebpack(grunt, config) {
19
- const { NODE_ENV = 'development' } = process.env;
20
- const watch = !!grunt.option('watch');
21
- const verbose = !!grunt.option('verbose');
22
- const noMinify = !!grunt.option('no-minify');
23
- const analyze = !!grunt.option('analyze');
24
- const lint = NODE_ENV === 'test' || !!grunt.option('lint');
20
+ const { NODE_ENV = "development" } = process.env;
21
+ const watch = !!grunt.option("watch");
22
+ const verbose = !!grunt.option("verbose");
23
+ const noMinify = !!grunt.option("no-minify");
24
+ const analyze = !!grunt.option("analyze");
25
+ const lint = NODE_ENV === "test" || !!grunt.option("lint");
25
26
 
26
27
  for (const target in config.webpack) {
27
28
  const targetConfig = config.webpack[target];
@@ -42,45 +43,67 @@ module.exports = function configureWebpack(grunt, config) {
42
43
  // This prevents Webpack from loading every single locale definition file that Moment.js provides.
43
44
  // 99% of the time we only care about formatting dates in US English, so we have no need for i.e.
44
45
  // the preferred date formats of Esperanto-speaking residents of Papua New Guinea. American cultural hedgemony FTW!
45
- const momentLocales = new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /en/);
46
+ const momentLocales = new webpack.ContextReplacementPlugin(
47
+ /moment[/\\]locale$/,
48
+ /en/
49
+ );
46
50
 
47
- let plugins = [ environmentVars, momentLocales ];
51
+ let plugins = [environmentVars, momentLocales];
48
52
 
49
53
  if (!config.babelLoader) {
50
- config.babelLoader = { exceptions: [], exclude: /(node_modules|bower_components)/ };
54
+ config.babelLoader = {
55
+ exceptions: [],
56
+ exclude: /(node_modules|bower_components)/,
57
+ };
51
58
  }
52
59
 
53
60
  const babelExclude = config.babelLoader.exclude;
54
- const babelExceptions = config.babelLoader.exceptions.map((mod) => new RegExp(`node_modules/${mod}/(.+)\\.js$`));
61
+ const babelExceptions = config.babelLoader.exceptions.map(
62
+ (mod) => new RegExp(`node_modules/${mod}/(.+)\\.js$`)
63
+ );
55
64
 
56
- targetConfig.watch = watch;
57
- targetConfig.keepalive = watch || analyze;
58
- targetConfig.stats.modules = verbose;
59
- targetConfig.stats.reasons = verbose;
60
- targetConfig.profile = analyze;
65
+ targetConfig.watch = watch;
66
+ targetConfig.keepalive = watch || analyze;
67
+ targetConfig.stats.modules = verbose;
68
+ targetConfig.stats.reasons = verbose;
69
+ targetConfig.profile = analyze;
61
70
 
62
71
  // Tell babel-plugin-lodash where to find modularized Lo-Dash functions:
63
72
  targetConfig.resolve.alias.lodash = lodashDir;
64
73
 
65
74
  const babelOptions = {
66
75
  presets: [
67
- [require.resolve('@epublishing/babel-preset-epublishing'), {
68
- lodash: { cwd: moduleDir },
69
- env: {
70
- modules: false,
76
+ [
77
+ require.resolve("@epublishing/babel-preset-epublishing"),
78
+ {
79
+ lodash: { cwd: moduleDir },
80
+ env: {
81
+ modules: false,
82
+ },
83
+ minify: false,
71
84
  },
72
- minify: false,
73
- }],
85
+ ],
74
86
  ],
75
- }
87
+ plugins: [
88
+ [
89
+ require.resolve("babel-plugin-transform-react-jsx"),
90
+ {
91
+ pragma: "h",
92
+ // pragmaFrag: "Fragment",
93
+ },
94
+ ],
95
+ ],
96
+ };
76
97
 
77
98
  const rules = [
78
99
  {
79
100
  test: /\.jsx?$/,
80
- loader: 'babel-loader',
101
+ loader: "babel-loader",
81
102
  exclude: (input) => {
82
103
  // Check whether the asset has a matching exclusion exception pattern and allow it to transpile if it does:
83
- const isException = babelExceptions.some((pattern) => pattern.test(input));
104
+ const isException = babelExceptions.some((pattern) =>
105
+ pattern.test(input)
106
+ );
84
107
  if (isException) return !isException;
85
108
 
86
109
  // Test asset against the default exclusion pattern and return result:
@@ -93,44 +116,43 @@ module.exports = function configureWebpack(grunt, config) {
93
116
  exclude: /node_modules/,
94
117
  use: [
95
118
  {
96
- loader: 'babel-loader',
119
+ loader: "babel-loader",
97
120
  options: babelOptions,
98
121
  },
99
122
  {
100
- loader: 'ts-loader',
123
+ loader: "ts-loader",
101
124
  },
102
125
  ],
103
126
  },
104
127
  {
105
128
  test: /\.css$/,
106
- use: [
107
- 'style-loader',
108
- 'css-loader',
109
- ],
129
+ use: ["style-loader", "css-loader"],
110
130
  },
111
131
  {
112
- test: [ /\.svg$/, /\.jpe?g$/, /\.gif$/, /\.png$/ ],
113
- loader: 'file-loader',
132
+ test: [/\.svg$/, /\.jpe?g$/, /\.gif$/, /\.png$/],
133
+ loader: "file-loader",
114
134
  },
115
135
  ];
116
136
 
117
137
  if (lint) {
118
- const localEslintConfig = path.join(process.cwd(), '.eslintrc');
119
- const globalEslintConfig = path.resolve(__dirname, '../.eslintrc');
120
- const eslintConfig = fs.existsSync(localEslintConfig) ? localEslintConfig : globalEslintConfig;
138
+ const localEslintConfig = path.join(process.cwd(), ".eslintrc");
139
+ const globalEslintConfig = path.resolve(__dirname, "../.eslintrc");
140
+ const eslintConfig = fs.existsSync(localEslintConfig)
141
+ ? localEslintConfig
142
+ : globalEslintConfig;
121
143
 
122
144
  rules.push({
123
- enforce: 'pre',
145
+ enforce: "pre",
124
146
  test: /\.js$/,
125
147
  exclude: /(node_modules|bower_components|public|vendor)/,
126
- loader: 'eslint-loader',
148
+ loader: "eslint-loader",
127
149
  options: {
128
150
  configFile: eslintConfig,
129
- formatter: require('eslint-friendly-formatter'),
151
+ formatter: require("eslint-friendly-formatter"),
130
152
  failOnError: true,
131
153
  outputReport: {
132
- filePath: 'eslint.xml',
133
- formatter: require('eslint/lib/formatters/junit'),
154
+ filePath: "eslint.xml",
155
+ formatter: require("eslint/lib/formatters/junit"),
134
156
  },
135
157
  },
136
158
  });
@@ -140,14 +162,14 @@ module.exports = function configureWebpack(grunt, config) {
140
162
 
141
163
  if (analyze) {
142
164
  const bundleAnalyzer = new BundleAnalyzerPlugin({
143
- analyzerMode: 'server',
144
- analyzerHost: '127.0.0.1',
145
- analyzerPort: '8888',
146
- reportFilename: 'webpack-analysis.html',
147
- defaultSizes: 'parsed',
165
+ analyzerMode: "server",
166
+ analyzerHost: "127.0.0.1",
167
+ analyzerPort: "8888",
168
+ reportFilename: "webpack-analysis.html",
169
+ defaultSizes: "parsed",
148
170
  openAnalyzer: true,
149
171
  generateStatsFile: true,
150
- statsFilename: 'webpack.stats.json',
172
+ statsFilename: "webpack.stats.json",
151
173
  statsOptions: { chunkModules: true },
152
174
  });
153
175
  plugins.push(bundleAnalyzer);
@@ -162,17 +184,21 @@ module.exports = function configureWebpack(grunt, config) {
162
184
  const { uglifyConfig = {} } = targetConfig;
163
185
  delete targetConfig.uglifyConfig;
164
186
 
165
- plugins.push(new UglifyJsPlugin(Object.assign({}, uglifyDefaults, uglifyConfig)));
187
+ plugins.push(
188
+ new UglifyJsPlugin(Object.assign({}, uglifyDefaults, uglifyConfig))
189
+ );
166
190
  }
167
191
 
168
- if (NODE_ENV === 'production') {
169
- plugins.push(new CompressionPlugin({
170
- asset: '[path].gz',
171
- algorithm: 'gzip',
172
- test: /\.js$/,
173
- threshold: 10240,
174
- minRatio: 0.8,
175
- }));
192
+ if (NODE_ENV === "production") {
193
+ plugins.push(
194
+ new CompressionPlugin({
195
+ asset: "[path].gz",
196
+ algorithm: "gzip",
197
+ test: /\.js$/,
198
+ threshold: 10240,
199
+ minRatio: 0.8,
200
+ })
201
+ );
176
202
  }
177
203
 
178
204
  if (Array.isArray(targetConfig.appendPlugins)) {
@@ -182,7 +208,10 @@ module.exports = function configureWebpack(grunt, config) {
182
208
 
183
209
  targetConfig.plugins = plugins;
184
210
 
185
- if (targetConfig.customize && typeof targetConfig.customize === 'function') {
211
+ if (
212
+ targetConfig.customize &&
213
+ typeof targetConfig.customize === "function"
214
+ ) {
186
215
  config.webpack[target] = targetConfig.customize(targetConfig, webpack);
187
216
  delete config.webpack[target].customize;
188
217
  }
@@ -7,7 +7,6 @@
7
7
 
8
8
  'use strict';
9
9
 
10
- const _ = require('lodash');
11
10
  const fs = require('fs');
12
11
  const prettyjson = require('prettyjson');
13
12
  const mergeConfigs = require('./merge-configs');
@@ -31,7 +30,7 @@ module.exports = function initJadeConfig(grunt, jadePath, jadeChildPath, jadeChi
31
30
  baseConfig = mergeConfigs(baseConfig, jadePath);
32
31
 
33
32
  // Loop through all detected engine gem paths and merge their Grunt configurations into baseConfig
34
- for (const childPath of _.values(jadeChildPaths)) {
33
+ for (const childPath of Object.values(jadeChildPaths)) {
35
34
  baseConfig = mergeConfigs(baseConfig, childPath);
36
35
  }
37
36
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epublishing/grunt-epublishing",
3
3
  "description": "Automated front-end tasks for ePublishing Jade and client sites.",
4
- "version": "0.3.1",
4
+ "version": "0.3.3",
5
5
  "homepage": "https://www.epublishing.com",
6
6
  "contributors": [
7
7
  {
@@ -11,21 +11,26 @@
11
11
  {
12
12
  "name": "Mike Green",
13
13
  "email": "mgreen@epublishing.com"
14
+ },
15
+ {
16
+ "name": "Michael Hedges",
17
+ "email": "mhedges@epublishing.com"
14
18
  }
15
19
  ],
16
20
  "repository": "bitbucket:epub_dev/grunt-epublishing",
17
21
  "license": "MIT",
18
22
  "engines": {
19
- "node": ">= 8.0.0"
23
+ "node": ">= 12.22.12"
20
24
  },
21
25
  "dependencies": {
22
- "@epublishing/babel-preset-epublishing": "^0.1.6",
26
+ "@epublishing/babel-preset-epublishing": "^0.1.8",
23
27
  "@epublishing/get-gem-paths": "^0.1.1",
24
28
  "@epublishing/grunt-install-eslint": "^0.1.1",
25
29
  "@epublishing/jade-resolver": "^0.1.2",
26
30
  "async": "^2.6.1",
27
31
  "babel-loader": "^7.1.5",
28
32
  "babel-minify-webpack-plugin": "^0.3.0",
33
+ "babel-plugin-transform-react-jsx": "^6.24.1",
29
34
  "bourbon": "^4.2.7",
30
35
  "breakpoint-sass": "^2.7.0",
31
36
  "chalk": "^2.4.1",
@@ -64,10 +69,10 @@
64
69
  "jit-grunt": "^0.10.0",
65
70
  "listr": "^0.14.1",
66
71
  "lodash": "^4.17.10",
67
- "node-sass": "^6.0.1",
68
72
  "postcss-css-variables": "^0.9.0",
69
73
  "prettyjson": "^1.2.1",
70
74
  "read-pkg": "^4.0.1",
75
+ "sass": "^1.71.1",
71
76
  "style-loader": "^0.20.2",
72
77
  "susy": "^2.2.14",
73
78
  "time-grunt": "^1.4.0",
package/tasks/jade.js CHANGED
@@ -14,11 +14,19 @@ const initJadeConfig = require('../lib/init-jade-config');
14
14
  module.exports = function(grunt) {
15
15
  grunt.option('siteRoot', process.cwd())
16
16
 
17
+ console.log('~~~~~~~~~~~~~~~~~~~~')
18
+ console.log('~~~~~~~DEBUG~~~~~~~~')
19
+ console.log('~~~~~~~~~~~~~~~~~~~~')
20
+
21
+
17
22
  if (!grunt.option('no-time')) timeGrunt(grunt);
23
+
18
24
  jitGrunt(grunt, {
19
25
  'install-eslint': '@epublishing/grunt-install-eslint',
20
26
  });
21
27
 
28
+
29
+
22
30
  /**
23
31
  * This registers a grunt task which shells out and uses bundler to
24
32
  * determine the paths to the jade gem and any jade child engine gem