在Webpack中填充Highcharts

时间:2015-11-19 09:41:36

标签: javascript highcharts webpack

我有webpack.config.js定义:

module.exports = {
    context: __dirname + "/app",

    output: {
        path: path.resolve(__dirname, "../Scripts"),
        filename: "bundle.js"
    },

    entry: ["./app.ts", "angular", "angular-ui-router", "jquery", path.join(__dirname, "vendor", "highcharts.src.js"), path.join(__dirname, "node_modules/angular-local-storage/dist", "angular-local-storage.js")],

    stats: "minimal",

    resolve: {
        extensions: ["", ".webpack.js", ".web.js", ".ts", ".js"]
    },

    plugins: [
        // new webpack.optimize.UglifyJsPlugin(),
        new webpack.ProvidePlugin({
            "Highcharts": "imports?this=>global!exports?global.Highcharts",
        })
    ],

    devtool: "source-map",

    module: {
        loaders: [
            { test: /\.html$/, loader: "raw", exclude: exclusionRegexs },
            { test: /\.css$/, loader: "style!css", exclude: exclusionRegexs },
            { test: /\.ts$/, loader: "ng-annotate!ts-loader", exclude: exclusionRegexs }
        ]
        /*preLoaders: [
            {
                test: /\.js$/, // include .js files
                exclude: /node_modules/, // exclude any and all files in the node_modules folder
                loader: "jshint-loader"
            }
        ]*/
    }
};

这一行应该导出highcharts,然后直接将highcharts导入到window对象中,这就是我想要做的,但它并不完全存在。有一个example,演示了如何做到这一点。

new webpack.ProvidePlugin({
    "Highcharts": "imports?this=>global!exports?global.Highcharts",
})

在highcharts中,src是:

Highcharts = win.Highcharts = win.Highcharts ? error(16, true) : {};

显然它正被放在窗户上。

我认为它与entry内容有关,在该数组中有一条路径直接指向定义高图的正确位置,并正确捆绑它。

我认为某处我没有将ProvidePlugin highcharts条目与源条目链接起来?

我从webpack构建输出获得的当前错误是:

  

找不到模块:错误:无法解析模块'exports'

0 个答案:

没有答案
相关问题