В папке
config/ лежит файл
webpack.config.ts, запускаю его при помощи
webpack.config.js:
require('ts-node').register({
project: 'tsconfig.tsnode.json'
});
module.exports = require('./config/webpack.config').default;
Но получаю
implicitly has an 'any' type.
Try `npm install @types/webpack` if it exists or add a new declaration (.d.ts) file containing `declare module 'webpack';` (7016)
config\webpack.config.ts (4,38): Cannot find name '__dirname'. (2304)P.S. d.ts не помог
Как правильно записать? Заранее спасибо:
import * as path from "path";
import * as webpack from "webpack";
const projectRootPath = path.resolve(__dirname, '../');
const config = webpack.Configuration = {
context: path.resolve(__dirname, '..'),
entry: ["./src/app.tsx"],
output: {
filename: "bundle.js",
path: path.resolve(__dirname, './public/js'),
publicPath: path.resolve(__dirname, '/public/')
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: '/node_modules/',
use: {
loader: "ts",
presets: ['react']
}
}
]
},
resolve: {
extensions: ["*", ".webpack.js", ".jsx", ".ts", ".tsx", ".js"]
},
watch: true
};
export default config;