webpack: config to ts

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/888/head
Varun Patil 2023-10-19 11:42:16 -07:00
parent 03d86e79dc
commit bcd1764779
3 changed files with 19 additions and 15 deletions

View File

@ -23,10 +23,10 @@
"license": "agpl", "license": "agpl",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "webpack --node-env production --progress --config webpack.js", "build": "webpack --node-env production --progress",
"dev": "webpack --node-env development --progress --config webpack.js", "dev": "webpack --node-env development --progress",
"watch": "webpack --node-env development --progress --watch --config webpack.js", "watch": "webpack --node-env development --progress --watch",
"serve": "webpack serve --node-env development --progress --config webpack.js", "serve": "webpack serve --node-env development --progress",
"e2e": "playwright test" "e2e": "playwright test"
}, },
"dependencies": { "dependencies": {

View File

@ -9,7 +9,6 @@
"moduleResolution": "node", "moduleResolution": "node",
"sourceMap": true, "sourceMap": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"jsx": "preserve",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"noImplicitThis": true, "noImplicitThis": true,
"noImplicitAny": true, "noImplicitAny": true,
@ -18,5 +17,10 @@
}, },
"vueCompilerOptions": { "vueCompilerOptions": {
"target": 2.7 "target": 2.7
} },
"ts-node": {
"compilerOptions": {
"module": "CommonJS",
}
},
} }

View File

@ -1,13 +1,13 @@
const webpack = require('webpack'); import webpack from 'webpack';
const path = require('path'); import path from 'path';
const WorkboxPlugin = require('workbox-webpack-plugin'); import WorkboxPlugin from 'workbox-webpack-plugin';
const TerserPlugin = require('terser-webpack-plugin'); import TerserPlugin from 'terser-webpack-plugin';
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin'); import NodePolyfillPlugin from 'node-polyfill-webpack-plugin';
const { VueLoaderPlugin } = require('vue-loader'); import { VueLoaderPlugin } from 'vue-loader';
const appName = process.env.npm_package_name; const appName = process.env.npm_package_name!;
const appVersion = process.env.npm_package_version; const appVersion = process.env.npm_package_version!;
const buildMode = process.env.NODE_ENV; const buildMode = process.env.NODE_ENV;
const isDev = buildMode === 'development'; const isDev = buildMode === 'development';
console.info('Building', appName, appVersion, '\n'); console.info('Building', appName, appVersion, '\n');
@ -38,7 +38,7 @@ module.exports = {
// Make sure sourcemaps have a proper path and do not // Make sure sourcemaps have a proper path and do not
// leak local paths https://github.com/webpack/webpack/issues/3603 // leak local paths https://github.com/webpack/webpack/issues/3603
devtoolNamespace: appName, devtoolNamespace: appName,
devtoolModuleFilenameTemplate(info) { devtoolModuleFilenameTemplate(info: any) {
const rootDir = process.cwd(); const rootDir = process.cwd();
const rel = path.relative(rootDir, info.absoluteResourcePath); const rel = path.relative(rootDir, info.absoluteResourcePath);
return `webpack:///${appName}/${rel}`; return `webpack:///${appName}/${rel}`;