Webpack Angular 2捆绑整个项目在单个文件中

时间:2017-02-05 22:50:22

标签: javascript angular webpack

我正在尝试将整个Angular 2项目捆绑在一个index.html文件中(js,fonts,css和images)。

下面是我当前的webpack配置文件,如果可能的话,我该怎么做或更新以将所有文件捆绑在一起(使用地图文件)?

var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');

    module.exports = {

        entry: './app/main.ts',
        output : {
            path: './dist',
            filename: 'app.bundle.js'
        },
        module: {
            preLoaders: [
                {
                    test: /\.ts$/,
                    loader: 'tslint'
                }
            ],
            loaders : [
                { 
                    test: /\.ts$/, 
                    loaders: ['awesome-typescript-loader', 'angular2-template-loader']
                },
                {
                    test: /\.(html)$/, 
                    loader: 'raw-loader'
                },           
                {
                    test: /.(jpg|jpeg|gif|png|eot|ttf|svg|cur|woff(2)?)(\?[a-z0-9=\.]+)?$/,
                    loaders: ['raw-loader', 'url-loader']
                },
                {
                    test: /\.css$/,
                    loaders: ['style-loader', 'css-loader']
                },
                {
                    test: /\.scss$/,
                    exclude: /node_modules/,
                    loaders: ['style-loader', 'css-loader', 'sass-loader']
                },
            ]
        },
        resolve: {
            extensions: ['', '.ts', '.tsx', '.js', '.jsx']
        },
        plugins: [
            new HtmlWebpackPlugin({
                template: './index.html'
            }),
        ]
    };

0 个答案:

没有答案