2017-01-16 117 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