Webpack+Typescript 简易配置

教程:https://www.cnblogs.com/yasepix/p/9294499.html

npm install webpack webpack-cli typescript ts-loader --save-dev

  

webpack.config.js

module.exports = {
    mode: "development",
    entry: './src/index.ts',
    target: 'web',
    output: {
        filename: 'main.js',
        path: __dirname + "/dist",
        libraryTarget: 'umd',
        library: 'layx',
        libraryExport: 'default',
    },
    devtool: "source-map",
    module: {
        rules: [
            { test: /\.ts?$/, loader: "ts-loader" }
        ]
    },
    resolve: {
        extensions: [".ts", ".tsx", ".js"]
    }
}

  

tsconfig.js

{
    "compilerOptions": {
        "module": "commonjs",
        "noImplicitAny": true,
        "removeComments": true,
        "target": "es5",
        "sourceMap": true
    },
    "exclude": [
        "node_modules",
    ]
}

  

猜你喜欢

转载自www.cnblogs.com/baisoft/p/10372758.html