2017-01-16 118 views
0

目前,我使用HtmlWebpackPlugin和发展的热点重载生成包含的JavaScript捆绑的HTML文件如何减少进口文件。当HtmlWebpackPlugin使用

这正常工作与以下的WebPack配置:

const HtmlWebpackPlugin = require('html-webpack-plugin'); 
const webpack = require('webpack'); 
const path = require('path') 
const { NoErrorsPlugin, HotModuleReplacementPlugin } = webpack; 
const { OccurrenceOrderPlugin } = webpack.optimize; 

module.exports = { 
    entry : { 
     app: [ 
      'webpack-hot-middleware/client', 
      './src/index.tsx', 
     ], 
    }, 
    output: { 
     filename: "bundle.js", 
     path: path.join(__dirname, 'build'), 
     publicPath: '/static/' 
    }, 

    devtool: "eval", 

    resolve: { 
     // Add '.ts' and '.tsx' as resolvable extensions. 
     extensions: ["", ".webpack.js", ".web.js", ".ts", ".tsx", ".js"] 
    }, 

    module: { 
     loaders: [ 
      // All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'. 
      { test: /\.tsx?$/, loaders: ['react-hot-loader', 'awesome-typescript-loader'] } 
     ], 

     preLoaders: [ 
      // All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'. 
      { test: /\.js$/, loader: "source-map-loader" } 
     ] 
    }, 

    plugins: [ 
     new OccurrenceOrderPlugin(), 
     new HotModuleReplacementPlugin(), 
     new NoErrorsPlugin(), 
     new HtmlWebpackPlugin({ 
      filename: 'index.html', 
      template: 'src/templates/index.ejs', 
      minify: false, 
      excludeChunks: ['static'], 
     }), 
    ], 
}; 

但是,它不包括blueprintjs样式表。我应该如何配置呢?我试图less-loader但它并没有输入任何东西。

+0

使用一口呢? – Lukas

回答

0

可以在TS文件导入较少文件和配置的WebPack使用less-loader