1

目前,我正在使用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了,但它没有导入任何东西。

4

1 回答 1

1

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

于 2017-01-17T02:19:59.067 回答