webpackJsonp is not defined?

來源:互聯網
上載者:User

標籤:jsp   process   uil   dem   new   json   dir   檔案   node   

用了CommonsChunkPlugin產生了公用檔案,但是頁面還沒有引用這個公用檔案

比如下面這個配置

var webpack = require(‘webpack‘);var path = require(‘path‘);var buildPath = path.resolve(__dirname,"build");// var nodemodulesPath = path.resolve(__dirname,‘node_modules‘);var config = {    //入口檔案配置    entry:{        // app:path.resolve(__dirname,‘src/main.js‘),        main:path.resolve(__dirname,‘src/main.js‘),        main1:path.resolve(__dirname,‘src/main1.js‘),        common: ["./src/js/common"] //【1】注意這裡      },    resolve:{        extentions:["","js"]//當requrie的模組找不到時,添加這些尾碼    },    //檔案匯出的配置    output:{        path:buildPath,        filename:"[name].js"    },    // module: {    //     loaders: [{    //         test: /\.(js|jsx)$/,    //         loaders: [‘babel‘],    //         exclude: /(node_modules|bower_components)/    //         //排除不處理的目錄    //     }]    // },    plugins: [        new webpack.DefinePlugin({          ‘process.env‘: {            ‘NODE_ENV‘: ‘"production"‘          }        }),         //【2】注意這裡  這兩個地方市用來配置common.js模組單獨打包的         new webpack.optimize.CommonsChunkPlugin({            name: "common",//和上面配置的入口對應            filename: "commonFun.js"//匯出的檔案的名稱        })         //壓縮打包的檔案        // new webpack.optimize.UglifyJsPlugin(),        // new webpack.optimize.OccurenceOrderPlugin(),        // new webpack.optimize.AggressiveMergingPlugin(),         //允許錯誤不打斷程式        // new webpack.NoErrorsPlugin()    ]}module.exports = config;

  

產生了公用的檔案,檔案名稱為commonFun.js,需要在index.html裡首先引入commonFun.js,然後再引入打包的js檔案才行

webpackJsonp is not defined?

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.