首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >webpack观看模式导致visual studio 2015运行时出现异常

webpack观看模式导致visual studio 2015运行时出现异常
EN

Stack Overflow用户
提问于 2016-04-28 11:07:26
回答 1查看 492关注 0票数 1

我已经安装了webpack插件到视觉工作室。除了在运行时使用手表模式外,它一直运行良好。它适用于正常运行选项,但每次更改后使用该选项需要花费大量时间。此外,run选项构建所有入口点,而不仅仅是更改的入口点。

我确实有例外:

InvalidOperationException未被处理

System.InvalidOperationException类型的未处理异常发生在mscorlib.dll中

然后进入中断模式。如其所述:

应用程序处于中断模式,应用程序已进入中断状态,但没有显示代码,因为所有线程都在执行外部代码(通常是系统或框架代码)。

我希望能帮上忙

代码语言:javascript
运行
复制
/// <binding Clean='Watch - Development' />

AssetsPlugin = require('assets-webpack-plugin');
path = require('path');
pkg = require('./package.json');
webpack = require('webpack');


var production = process.env.NODE_ENV === 'production';
var config = require("./webpack.config.js");
BUILD_DIRECTORY = 'build';
BUILD_DROP_PATH = path.resolve(__dirname, BUILD_DIRECTORY);
CHUNK_FILE_NAME = '[name].js';
WEB_ROOT = path.resolve(__dirname, 'Scripts/WS2');


module.exports = {
    context: WEB_ROOT,
    entry: {
        ITOps_ProfilePage_ShowPage: "./ItOps/Pages/ProfilePage/ProfilePage",
        ITOps_TestPage_ShowPage: "./ItOps/Pages/TestPage/TestPage",
        LayoutWS2: './Common/LayoutWS2',
        vendor: Object.keys(pkg.dependencies)
    },
    output: {
        chunkFilename: CHUNK_FILE_NAME,
        filename: CHUNK_FILE_NAME,
        libraryTarget: 'var',
        publicPath:'/build/',
        path: BUILD_DROP_PATH
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                loader: 'babel-loader',
                include: [
                    path.resolve(__dirname, 'Scripts/WS2'),
                    path.resolve(__dirname, 'node_modules', 'prosemirror')
                ],
                // Need this here for prosemirror til it has own .babelrc
                query: {
                    presets: ['es2015-webpack'],
                    plugins: [
                        ["transform-es2015-modules-commonjs-simple", {
                            noMangle: true
                        }]
                    ]
                    
                }
            },
            { test: /\.css$/, loader: "style-loader!css-loader" },
            { test: /\.html/, loader: 'html' },
            { test: /\.(png|gif|jpe?g|svg)$/i, loader: 'url?limit=10000' },
            { test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/font-woff' },
            { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/octet-stream' },
            { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file' },
            { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=image/svg+xml' }
        ],
    },
    plugins: [
        new AssetsPlugin({
            filename: 'webpack.assets.json',
            path: BUILD_DROP_PATH,
            prettyPrint: true
        }),  
        new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.js"),
        new webpack.ProvidePlugin({
             $: "jquery",
             jQuery: "jquery"
         })

    ],

    if (production) {
        plugins = plugins.concat([

            // This plugin looks for similar chunks and files
            // and merges them for better caching by the user
            new webpack.optimize.DedupePlugin(),

            // This plugins optimizes chunks and modules by
            // how much they are used in your app
            new webpack.optimize.OccurenceOrderPlugin(),

            // This plugin prevents Webpack from creating chunks
            // that would be too small to be worth loading separately
            new webpack.optimize.MinChunkSizePlugin({
                minChunkSize: 51200, // ~50kb
            }),

            // This plugin minifies all the Javascript code of the final bundle
            new webpack.optimize.UglifyJsPlugin({
                mangle: true,
                comments: false,
                compress: {
                    warnings: false, // Suppress uglification warnings
                },
            }),

            // This plugins defines various variables that we can set to false
            // in production to avoid code related to them from being compiled
            // in our final bundle
            new webpack.DefinePlugin({
                __SERVER__: !production,
                __DEVELOPMENT__: !production,
                __DEVTOOLS__: !production,
                'process.env': {
                    BABEL_ENV: JSON.stringify(process.env.NODE_ENV),
                },
            }),

        ]);
    }
};

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-05-03 12:58:58

我查看了您的webpack.config文件,没有看到任何明显的东西,但是您正在使用一些我没有使用过的特性/插件。

我不知道这是否有帮助,但我可以让webpack手表工作。它没有抛出异常,但它只是没有捕捉到对文件的任何更改。

经过大量的搜索之后,我发现了这个所以回答,它说要使用旧的手表插件,现在它可以工作了!在webpack.config中添加以下内容:

代码语言:javascript
运行
复制
plugins: [
     new webpack.OldWatchingPlugin(),
     ... other plugins
],

注意:我在Visual 2015中使用webpack版本1.12.15。

如果这能解决问题请告诉我。

PS。对于在Visual中有问题的其他人,请阅读寡妇路径上的WebPack TroubleShooting指南

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36912837

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档