ultimate-jekyll-manager 0.0.201 → 0.0.202
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.
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webpack Loader: strip-dev-blocks-loader
|
|
3
|
+
* Strips code between /* @dev-only:start * / and /* @dev-only:end * / markers
|
|
4
|
+
* Runs before webpack bundles, so the source code is still clean
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const START_MARKER = '/* @dev-only:start */';
|
|
8
|
+
const END_MARKER = '/* @dev-only:end */';
|
|
9
|
+
|
|
10
|
+
function escapeRegex(str) {
|
|
11
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = function stripDevBlocksLoader(source) {
|
|
15
|
+
// Only strip in build mode
|
|
16
|
+
if (process.env.UJ_BUILD_MODE !== 'true') {
|
|
17
|
+
return source;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Strip everything between start and end markers
|
|
21
|
+
const pattern = new RegExp(
|
|
22
|
+
`${escapeRegex(START_MARKER)}[\\s\\S]*?${escapeRegex(END_MARKER)}`,
|
|
23
|
+
'g'
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return source.replace(pattern, '');
|
|
27
|
+
};
|
package/dist/gulp/tasks/sass.js
CHANGED
|
@@ -12,7 +12,7 @@ const filter = require('gulp-filter').default;
|
|
|
12
12
|
const { template } = require('node-powertools');
|
|
13
13
|
const yaml = require('js-yaml');
|
|
14
14
|
const postcss = require('gulp-postcss');
|
|
15
|
-
const purgeCss = require('@fullhuman/postcss-purgecss')
|
|
15
|
+
const purgeCss = require('@fullhuman/postcss-purgecss');
|
|
16
16
|
const through2 = require('through2');
|
|
17
17
|
|
|
18
18
|
// Load package
|
|
@@ -7,7 +7,7 @@ const path = require('path');
|
|
|
7
7
|
const jetpack = require('fs-jetpack');
|
|
8
8
|
const wp = require('webpack');
|
|
9
9
|
const ReplacePlugin = require('../plugins/webpack/replace.js');
|
|
10
|
-
const
|
|
10
|
+
const stripDevBlocksLoader = require.resolve('../loaders/webpack/strip-dev-blocks-loader.js');
|
|
11
11
|
const yaml = require('js-yaml');
|
|
12
12
|
const version = require('wonderful-version');
|
|
13
13
|
|
|
@@ -113,7 +113,6 @@ function getSettings() {
|
|
|
113
113
|
// devtool: 'source-map',
|
|
114
114
|
// devtool: false,
|
|
115
115
|
plugins: [
|
|
116
|
-
new StripDevBlocksPlugin(),
|
|
117
116
|
new ReplacePlugin(getTemplateReplaceOptions(), { type: 'template' }),
|
|
118
117
|
// new wp.IgnorePlugin({
|
|
119
118
|
// resourceRegExp: /^\.\/locale$/,
|
|
@@ -221,24 +220,27 @@ function getSettings() {
|
|
|
221
220
|
{
|
|
222
221
|
test: /\.js$/,
|
|
223
222
|
exclude: /node_modules/,
|
|
224
|
-
use:
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
223
|
+
use: [
|
|
224
|
+
{
|
|
225
|
+
loader: 'babel-loader',
|
|
226
|
+
options: {
|
|
228
227
|
sourceMaps: !Manager.actLikeProduction(),
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
228
|
+
presets: [
|
|
229
|
+
[require.resolve('@babel/preset-env', {
|
|
230
|
+
paths: [path.resolve(process.cwd(), 'node_modules', package.name, 'node_modules')]
|
|
231
|
+
}), {
|
|
232
|
+
exclude: [
|
|
233
|
+
// Prevent lighthouse error in 2025 about Legacy JavaScript
|
|
234
|
+
// 'es.array.from',
|
|
235
|
+
]
|
|
236
|
+
}]
|
|
237
|
+
],
|
|
238
|
+
compact: Manager.isBuildMode(),
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
// Strip dev-only blocks before babel processes the file
|
|
242
|
+
stripDevBlocksLoader,
|
|
243
|
+
]
|
|
242
244
|
},
|
|
243
245
|
// {
|
|
244
246
|
// test: /\.js$/,
|
package/package.json
CHANGED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// Plugin: StripDevBlocksPlugin
|
|
2
|
-
class StripDevBlocksPlugin {
|
|
3
|
-
constructor(options = {}) {
|
|
4
|
-
this.options = Object.assign(
|
|
5
|
-
{
|
|
6
|
-
fileTest: /\.js$/,
|
|
7
|
-
startMarker: '/* @dev-only:start */',
|
|
8
|
-
endMarker: '/* @dev-only:end */',
|
|
9
|
-
},
|
|
10
|
-
options
|
|
11
|
-
)
|
|
12
|
-
this.enabled = process.env.UJ_BUILD_MODE === 'true'
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
apply(compiler) {
|
|
16
|
-
if (!this.enabled) return
|
|
17
|
-
|
|
18
|
-
compiler.hooks.compilation.tap('StripDevBlocksPlugin', (compilation) => {
|
|
19
|
-
compilation.hooks.processAssets.tap(
|
|
20
|
-
{
|
|
21
|
-
name: 'StripDevBlocksPlugin',
|
|
22
|
-
stage: compilation.PROCESS_ASSETS_STAGE_OPTIMIZE,
|
|
23
|
-
},
|
|
24
|
-
(assets) => {
|
|
25
|
-
for (const filename in assets) {
|
|
26
|
-
if (!this.options.fileTest.test(filename)) continue
|
|
27
|
-
|
|
28
|
-
let source = assets[filename].source()
|
|
29
|
-
|
|
30
|
-
// Strip everything between start and end marker
|
|
31
|
-
const pattern = new RegExp(
|
|
32
|
-
`${this.escape(this.options.startMarker)}[\\s\\S]*?${this.escape(this.options.endMarker)}`,
|
|
33
|
-
'g'
|
|
34
|
-
)
|
|
35
|
-
source = source.replace(pattern, '')
|
|
36
|
-
|
|
37
|
-
compilation.updateAsset(
|
|
38
|
-
filename,
|
|
39
|
-
new compiler.webpack.sources.RawSource(source)
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
)
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
escape(str) {
|
|
48
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Export
|
|
53
|
-
module.exports = StripDevBlocksPlugin
|