TypeScript+Webpack环境搭建
webpack 插件系列
构建成功,触发系统通知
webpack-build-notifier
插件,使用方法示例
1 2 3 4 5 6 7 8 9 10 11 12 13
| const WebpackBuildNotifierPlugin = require('webpack-build-notifier');
module.exports = { plugins: [ new WebpackBuildNotifierPlugin({ title: "My Project Webpack Build", suppressSuccess: true }) ] };
|
构建过程友好日志
friendly-errors-webpack-plugin
插件,能够将构建过程中在控制台产生的不需要关心的日志信息清理,并自定义输出构建成功的提示。eg:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin'); module.exports = { devServer: { quiet: true }, plugins: [ new FriendlyErrorsWebpackPlugin({ compilationSuccessInfo: { messages: ['You application is running here http://localhost:3000'], notes: ['Some additionnal notes to be displayed unpon successful compilation'] }, onErrors: (severity, errors) => { }, clearConsole: true }), ] };
|
loader
typescript loader
awesome-typescript-loader
loader,用于处理ts代码。eg:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| const { CheckerPlugin } = require('awesome-typescript-loader') module.exports = { resolve: { extensions: ['.ts', '.tsx', '.js', '.jsx'] }, devtool: 'source-map', module: { rules: [ { test: /\.tsx?$/, loader: 'awesome-typescript-loader' } ] }, plugins: [ new CheckerPlugin() ] };
|