2017-10-27 1 views
0

webpack을 사용하여 vue.js를 사용하는 dotnet core 2.0 앱이 있습니다. 오늘까지는 정상적으로 작동했습니다. 나는 webpack 설정에서 아무것도 변경하지 않았고 그 구성 요소 코드와 관련이 없다고 생각합니다.vue가 messange를 두 번로드하는 중

main.js 및 vendor.js에서 vue.js의 코드가 있는데, vue가 내 페이지에서 nextTick 로그 메시지를 두 번 가져 오는 이유는 두 번 발생하기 때문입니다.

어떤 아이디어가 있습니까?

console.log

내 웹팩 공급 업체 설정

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() 
     ]) 
    }]; 
}; 

내 웹팩 설정

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

참고 : 그래서 어쩌면 내가 말을하고 무엇을하지 최근 웹팩 및 뷰 사용한 적이 쓰레기를 완전히 버리십시오.

스크린 샷의 맨 오른쪽을 보면 로그 메시지의 출처를 알 수 있습니다. 하나는 vue.js이고 다른 하나는 생성 된 vendor.js입니다. 보통 vue.js 파일을로드하는 스크립트 태그가있을 수 있습니다.

Vue 변수 (올바르게 작성한 경우 앱을 만드는 데 사용됨)가 마지막에로드 된 항목으로 덮어 써 져야하므로이 코드가 코드에 어떤 영향을 미치는지 확신 할 수 없습니다.

관련 문제