2017-10-27 8 views
0

vue.jsをwebpackで使用しているdotnet core 2.0アプリは、今日まで正常に動作しています。私はwebpackの設定で何も変更していないと私はそのコンポーネントのコードに関連すると思ういけない。vue load messange twice

main.jsとvendor.jsのvue.jsのコードがあり、vueが2回起動するようにnextTickログメッセージが2回表示されます。

console.log

私のWebPACKベンダーの設定

const path = require('path'); 
const webpack = require('webpack'); 
const ExtractTextPlugin = require('extract-text-webpack-plugin'); 
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin'); 

module.exports = (env) => { 
    const extractCSS = new ExtractTextPlugin('vendor.css'); 
    const isDevBuild = !(env && env.prod); 
    return [{ 
     stats: { modules: false }, 
     resolve: { 
      extensions: ['.js'] 
     }, 
     module: { 
      rules: [ 
       { test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, use: 'url-loader?limit=100000' }, 
       { test: /\.css(\?|$)/, use: extractCSS.extract(['css-loader']) } 
      ] 
     }, 
     entry: { 
      vendor: ['bootstrap', 'bootstrap/dist/css/bootstrap.css', 'event-source-polyfill', 'vue', 'vuex', 
      'axios', 'vue-router', 'jquery', 'vue-progressbar', 'vue-notification'], 
     }, 
     output: { 
      path: path.join(__dirname, 'wwwroot', 'dist'), 
      publicPath: '/dist/', 
      filename: '[name].js', 
      library: '[name]_[hash]', 
     }, 
     plugins: [ 
      extractCSS, 
      // Compress extracted CSS. 
      new OptimizeCSSPlugin({ 
       cssProcessorOptions: { 
        safe: true 
       } 
      }), 
      new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable) 
      new webpack.DllPlugin({ 
       path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'), 
       name: '[name]_[hash]' 
      }), 
      new webpack.DefinePlugin({ 
       'process.env.NODE_ENV': isDevBuild ? '"development"' : '"production"' 
      }) 
     ].concat(isDevBuild ? [] : [ 
      new webpack.optimize.UglifyJsPlugin() 
     ]) 
    }]; 
}; 

私のWebPACKの設定

const path = require('path'); 
const webpack = require('webpack'); 
const ExtractTextPlugin = require('extract-text-webpack-plugin'); 
const bundleOutputDir = './wwwroot/dist'; 

module.exports = (env) => { 
    const isDevBuild = !(env && env.prod); 
    return [{ 
     stats: { modules: false }, 
     entry: { 'main': './ClientApp/boot-app.js' }, 
     resolve: { 
      extensions: ['.js', '.vue'], 
      alias: { 
       'vue$': 'vue/dist/vue', 
       'components': path.resolve(__dirname, './ClientApp/components'), 
       'views': path.resolve(__dirname, './ClientApp/views'), 
       'utils': path.resolve(__dirname, './ClientApp/utils'), 
       'api': path.resolve(__dirname, './ClientApp/store/api') 
      } 
     }, 
     output: { 
      path: path.join(__dirname, bundleOutputDir), 
      filename: '[name].js', 
      publicPath: '/dist/' 
     }, 
     module: { 
      rules: [ 
       { test: /\.vue$/, include: /ClientApp/, use: 'vue-loader' }, 
       { test: /\.js$/, include: /ClientApp/, use: 'babel-loader' }, 
       { test: /\.css$/, use: isDevBuild ? ['style-loader', 'css-loader'] : ExtractTextPlugin.extract({ use: 'css-loader' }) }, 
       { test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' } 
      ] 
     }, 
     plugins: [ 
      new webpack.DllReferencePlugin({ 
       context: __dirname, 
       manifest: require('./wwwroot/dist/vendor-manifest.json') 
      }) 
     ].concat(isDevBuild ? [ 
      // Plugins that apply in development builds only 
      new webpack.SourceMapDevToolPlugin({ 
       filename: '[file].map', // Remove this line if you prefer inline source maps 
       moduleFilenameTemplate: path.relative(bundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk 
      }) 
     ] : [ 
       // Plugins that apply in production builds only 
       new webpack.optimize.UglifyJsPlugin(), 
       new ExtractTextPlugin('site.css') 
      ]) 
    }]; 
}; 

答えて

0

注:私はので、多分、私が言っているものです、ない最近のWebPACKとVueの使用したことがありませんごみを完全に取り除く。

スクリーンショットの右端を見ると、ログメッセージの送信元がわかります。 1つはvue.js、もう1つはvendor.jsです。あなたはまだ普通のvue.jsファイルを読み込むスクリプトタグを持っているかもしれません。

Vue変数(私が正しくリコールすれば、アプリケーションを作成するために使用される)は、最後にロードされたものによって上書きされる必要があるため、コードに何らかの影響があるかどうかはわかりません。