Skip to content

Commit

Permalink
WIP migrate webpack-css
Browse files Browse the repository at this point in the history
For some reason, Webpack doesn't bundle the files; the final size is 70 bytes (expected 1450)
  • Loading branch information
kytta committed Sep 12, 2023
1 parent 064d085 commit 09dd4ac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
7 changes: 5 additions & 2 deletions packages/webpack-css/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
let CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)

const cssRule = {
exclude: /\.module\.css$/,
Expand Down Expand Up @@ -44,4 +47,4 @@ let self = {
name: '@size-limit/webpack-css'
}

module.exports = [self]
export default [self]
1 change: 1 addition & 0 deletions packages/webpack-css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"author": "Andrey Sitnik <andrey@sitnik.ru>",
"license": "MIT",
"repository": "ai/size-limit",
"type": "module",
"engines": {
"node": "^18.0.0 || >=20.0.0"
},
Expand Down
19 changes: 12 additions & 7 deletions packages/webpack-css/test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
let [webpack] = require('@size-limit/webpack')
let { join } = require('path')
let [file] = require('@size-limit/file')
let rm = require('size-limit/rm')
import filePlugins from '@size-limit/file'
import webpackPlugins from '@size-limit/webpack'
import { join } from 'node:path'
import rm from 'size-limit/rm'
import { afterEach, expect, it, vi } from 'vitest'

let [webpackCss] = require('../')
import webpackCssPlugins from '../'
let [webpack] = webpackPlugins
let [file] = filePlugins

let [webpackCss] = webpackCssPlugins

const DIST = join(process.cwd(), 'dist')

Expand All @@ -25,7 +30,7 @@ async function run(config) {
}
afterEach(async () => {
await rm(DIST)
jest.clearAllMocks()
vi.clearAllMocks()
})

it('supports non-JS require', async () => {
Expand All @@ -38,7 +43,7 @@ it('supports non-JS require', async () => {
})

it('applies both `modifyWebpackConfig`', async () => {
let { DefinePlugin } = require('webpack')
let { DefinePlugin } = await import('webpack')
let plugin = new DefinePlugin({
TEST: 'true'
})
Expand Down

0 comments on commit 09dd4ac

Please sign in to comment.