Skip to content

Commit

Permalink
refactor: align hash() with vite plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinjiang committed Jan 10, 2024
1 parent fb9656c commit a1c4cc1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { LoaderContext } from 'webpack'
import * as path from 'path'
import * as crypto from 'crypto'
import * as qs from 'querystring'

import hash = require('hash-sum')

import { compiler } from './compiler'
import type {
TemplateCompiler,
Expand Down Expand Up @@ -66,6 +65,10 @@ let errorEmitted = false
const { parse } = compiler
const exportHelperPath = require.resolve('./exportHelper')

function hash(text: string): string {
return crypto.createHash('sha256').update(text).digest('hex').substring(0, 8)
}

export default function loader(
this: LoaderContext<VueLoaderOptions>,
source: string
Expand Down
6 changes: 5 additions & 1 deletion test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
/* env jest */
import * as path from 'path'
import * as crypto from 'crypto'
import webpack from 'webpack'
import merge from 'webpack-merge'
import hash from 'hash-sum'
// import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import { fs as mfs } from 'memfs'
import { JSDOM, VirtualConsole } from 'jsdom'
import { VueLoaderPlugin } from '..'
import type { VueLoaderOptions } from '..'

function hash(text: string): string {
return crypto.createHash('sha256').update(text).digest('hex').substring(0, 8)
}

export const DEFAULT_VUE_USE = {
loader: 'vue-loader',
options: {
Expand Down

0 comments on commit a1c4cc1

Please sign in to comment.