@mpxjs/webpack-plugin 2.8.10 → 2.8.12

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.
@@ -119,7 +119,8 @@ module.exports = function (content) {
119
119
  if (err) return nativeCallback(err)
120
120
  let output = `var json = ${JSON.stringify(json, null, 2)};\n`
121
121
  if (processOutput) output = processOutput(output)
122
- output += 'module.exports = JSON.stringify(json, null, 2);\n'
122
+ const jsonSpace = this.minimize ? 0 : 2
123
+ output += `module.exports = JSON.stringify(json, null, ${jsonSpace});\n`
123
124
  nativeCallback(null, output)
124
125
  }
125
126
 
@@ -1189,8 +1189,8 @@ function parseMustache (raw = '') {
1189
1189
 
1190
1190
  if (i18n) {
1191
1191
  for (const i18nFuncName of i18nFuncNames) {
1192
- const funcNameRE = new RegExp(`${i18nFuncName}\\(`)
1193
- const funcNameREG = new RegExp(`${i18nFuncName}\\(`, 'g')
1192
+ const funcNameRE = new RegExp(`(?<![A-Za-z0-9_$.])${i18nFuncName}\\(`)
1193
+ const funcNameREG = new RegExp(`(?<![A-Za-z0-9_$.])${i18nFuncName}\\(`, 'g')
1194
1194
  if (funcNameRE.test(exp)) {
1195
1195
  if (i18n.useComputed || !i18nFuncName.startsWith('\\$')) {
1196
1196
  const i18nInjectComputedKey = `_i${i18nInjectableComputed.length + 1}`
@@ -144,6 +144,20 @@ module.exports = async function loader (content, map, meta) {
144
144
  )
145
145
  }
146
146
 
147
+ if (this.minimize) {
148
+ const cssnano = require('cssnano')
149
+ const minimizeOptions = rawOptions.minimize || {}
150
+ let cssnanoConfig = {
151
+ preset: ['cssnano-preset-default', minimizeOptions.optimisation || {}]
152
+ }
153
+ if (minimizeOptions.advanced) {
154
+ cssnanoConfig = {
155
+ preset: ['cssnano-preset-advanced', minimizeOptions.optimisation || {}]
156
+ }
157
+ }
158
+ plugins.push(cssnano(cssnanoConfig))
159
+ }
160
+
147
161
  // Reuse CSS AST (PostCSS AST e.g 'postcss-loader') to avoid reparsing
148
162
  if (meta) {
149
163
  const { ast } = meta
@@ -203,6 +203,11 @@
203
203
  "description": "Allows exporting styles as array with modules, string or constructable stylesheet (i.e. `CSSStyleSheet`).",
204
204
  "link": "https://github.com/webpack-contrib/css-loader#exporttype",
205
205
  "enum": ["array", "string", "css-style-sheet"]
206
+ },
207
+ "minimize": {
208
+ "description": "css minimization config.",
209
+ "link": "https://www.cssnano.cn/docs/what-are-optimisations/",
210
+ "type": "object"
206
211
  }
207
212
  },
208
213
  "type": "object"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.8.10",
3
+ "version": "2.8.12",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -82,5 +82,5 @@
82
82
  "engines": {
83
83
  "node": ">=14.14.0"
84
84
  },
85
- "gitHead": "f17e671af3371f763cdcdcc6afbb06100f1f054d"
85
+ "gitHead": "d1dbf93cab7f48e510cb911682ad48cfd086adbb"
86
86
  }