1- const path = require ( 'path' )
2- const crypto = require ( 'crypto' )
3- const CopyWebpackPlugin = require ( 'copy-webpack-plugin' )
4- const { CleanWebpackPlugin } = require ( 'clean-webpack-plugin' )
5- const MiniCssExtractPlugin = require ( 'mini-css-extract-plugin' )
1+ import * as path from 'path'
2+ import * as crypto from 'crypto'
3+ import * as webpack from 'webpack'
4+ import CopyWebpackPlugin from 'copy-webpack-plugin'
5+ import { CleanWebpackPlugin } from 'clean-webpack-plugin'
6+ import MiniCssExtractPlugin from 'mini-css-extract-plugin'
67
7- /**
8- * @type {import('webpack').Configuration[] }
9- */
10- const config = [
8+ const config : ( ( env : any , argv : any ) => webpack . Configuration ) [ ] = [
119 // Extension Configuration (Node.js environment)
12- ( env , argv ) => {
13- const is_production = argv . mode == 'production'
10+ ( env : any , argv : any ) : webpack . Configuration => {
11+ const is_production = argv . mode === 'production'
1412 return {
1513 name : 'extension' ,
1614 mode : is_production ? 'production' : 'development' ,
@@ -25,7 +23,7 @@ const config = [
2523 libraryTarget : 'commonjs2' ,
2624 devtoolModuleFilenameTemplate : '../[resource-path]'
2725 } ,
28- devtool : is_production ? false : 'eval-source-map' , // Use 'eval-source-map' for faster dev builds and good debugging
26+ devtool : is_production ? false : 'eval-source-map' ,
2927 cache : {
3028 type : 'filesystem' ,
3129 buildDependencies : {
@@ -74,7 +72,12 @@ const config = [
7472 . toString ( )
7573 . split ( '\n' )
7674 . slice ( 12 )
77- . filter ( ( line ) => ! [ '> [!TIP]' , '> [!IMPORTANT]' , '> [!NOTE]' ] . includes ( line . trim ( ) ) )
75+ . filter (
76+ ( line ) =>
77+ ! [ '> [!TIP]' , '> [!IMPORTANT]' , '> [!NOTE]' ] . includes (
78+ line . trim ( )
79+ )
80+ )
7881 . join ( '\n' )
7982 }
8083 }
@@ -85,8 +88,8 @@ const config = [
8588 }
8689 } ,
8790 // View Configuration (Web environment)
88- ( env , argv ) => {
89- const isProduction = argv . mode == 'production'
91+ ( env : any , argv : any ) : webpack . Configuration => {
92+ const isProduction = argv . mode === 'production'
9093 return {
9194 name : 'view' ,
9295 mode : isProduction ? 'production' : 'development' ,
@@ -103,7 +106,7 @@ const config = [
103106 performance : {
104107 hints : false
105108 } ,
106- devtool : isProduction ? false : 'eval-source-map' , // Use 'eval-source-map' for dev
109+ devtool : isProduction ? false : 'eval-source-map' ,
107110 cache : {
108111 type : 'filesystem' ,
109112 buildDependencies : {
@@ -132,12 +135,16 @@ const config = [
132135 loader : 'css-loader' ,
133136 options : {
134137 modules : {
135- getLocalIdent : ( context , _ , localName ) => {
138+ getLocalIdent : (
139+ context : webpack . LoaderContext < any > ,
140+ _ : any ,
141+ localName : string
142+ ) => {
136143 const filename = context . resourcePath
137144 const isModule = / \. m o d u l e \. ( s c s s | c s s ) $ / i. test ( filename )
138145 if ( isModule ) {
139146 const moduleName = path
140- . basename ( filename )
147+ . basename ( filename as string )
141148 . replace ( / \. m o d u l e \. ( s c s s | c s s ) $ / i, '' )
142149 const hash = crypto
143150 . createHash ( 'md5' )
@@ -157,7 +164,10 @@ const config = [
157164 loader : 'sass-loader' ,
158165 options : {
159166 additionalData : `@use "${ path
160- . resolve ( __dirname , '../../packages/ui/src/styles/foundation' )
167+ . resolve (
168+ __dirname ,
169+ '../../packages/ui/src/styles/foundation'
170+ )
161171 . replace ( / \\ / g, '/' ) } " as *;`
162172 }
163173 }
@@ -193,11 +203,11 @@ const config = [
193203 plugins : [
194204 new MiniCssExtractPlugin ( {
195205 filename : '[name].css'
196- } )
197- ] ,
206+ } ) as unknown as webpack . WebpackPluginInstance
207+ ] as webpack . WebpackPluginInstance [ ] ,
198208 stats : 'errors-only'
199209 }
200210 }
201211]
202212
203- module . exports = config
213+ export default config
0 commit comments