diff --git a/src/module.ts b/src/module.ts index a74e88a..800e95b 100644 --- a/src/module.ts +++ b/src/module.ts @@ -15,7 +15,7 @@ interface PluginOptions { filter?: Function; cache?: boolean; severityError?: boolean | string; - minimizerOptions: object; + minimizerOptions?: object; loader?: boolean; maxConcurrency?: number; filename?: string; @@ -36,7 +36,7 @@ const nuxtModule: Module = function (moduleOptions) { ['gifsicle', { interlaced: true }], ['jpegtran', { progressive: true }], ['optipng', { optimizationLevel: 5 }], - ['svgo', { plugins: [{ removeViewBox: false }] }] + ['svgo', { plugins: [{ name: 'removeViewBox', active: false }] }] ] } } diff --git a/test/fixture/assets/nuxt.svg b/test/fixture/assets/nuxt.svg new file mode 100644 index 0000000..2374eda --- /dev/null +++ b/test/fixture/assets/nuxt.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/test/fixture/pages/index.vue b/test/fixture/pages/index.vue index adf74da..551b391 100644 --- a/test/fixture/pages/index.vue +++ b/test/fixture/pages/index.vue @@ -2,5 +2,6 @@
Works! +
diff --git a/test/prod.test.ts b/test/prod.test.ts index 095feff..c8a8e21 100644 --- a/test/prod.test.ts +++ b/test/prod.test.ts @@ -13,10 +13,14 @@ describe('prod', () => { test('image minify', () => { const { options } = getNuxt() - const originalFileSize = statSync(resolve(options.rootDir, options.dir.assets, 'example.png')).size - const mapFiles = globSync(resolve(options.buildDir, 'dist/client/**/*.png')) - const minFileSize = statSync(mapFiles[0]).size + const files = [ + 'example.png', + 'nuxt.svg' + ] + const originalFileSizes = files.map(file => statSync(resolve(options.rootDir, options.dir.assets, file)).size) + const minFileSizes = files + .map(file => statSync(globSync(resolve(options.buildDir, 'dist/client/img', file.replace('.', '.*.')))[0]).size) - expect(originalFileSize).toBeGreaterThan(minFileSize) + originalFileSizes.forEach((oSize, index) => expect(oSize).toBeGreaterThan(minFileSizes[index])) }) })