使用HtmlWebpackPlugin时如何导入较少的文件

时间:2017-01-16 23:26:38

标签: reactjs webpack blueprintjs

目前,我正在使用HtmlWebpackPlugin和热重新加载进行开发,以生成包含javascript包的html文件。

这适用于以下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,但没有导入任何内容。

1 个答案:

答案 0 :(得分:1)

您可以在ts文件中导入less文件,并在webpack配置中使用less-loader

相关问题