vue ssr webpack配置

时间:2017-11-06 10:40:00

标签: express webpack vuejs2 vue-server-renderer vue-ssr

我有webpack.server.config

const merge = require('webpack-merge')
const webpack = require('webpack')
const nodeExternals = require('webpack-node-externals')
const baseConfig = require('./webpack.base.conf.js')
const VueSSRServerPlugin = require('vue-server-renderer/server-plugin')
const utils = require('./utils')
const config = require('../config')

module.exports = merge(baseConfig, {
  entry: './src/entry-server.js',
  target: 'node',
  devtool: 'source-map',
  output: {
    path: config.build.assetsRoot,
    filename: 'server.js',
    libraryTarget: 'commonjs2'
  },
  externals: nodeExternals({
    whitelist: /\.css$\.vue$/
  }),
  plugins: [
    new webpack.DefinePlugin({
      'process.env': 'production'
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    }),
    new VueSSRServerPlugin()
  ]
})

但如果我运行npm run build server - 抛出错误

ERROR in ./~/extract-text-webpack-plugin/loader.js?    {"omit":1,"remove":true}!./~/vue-style-loader!./~/css-loader?{"minimize":true,"sourceMap":true}!./~/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-42aa77cc","scoped":true,"hasInlineConfig":false}!./~/vue-loader/lib/selector.js?type=styles&index=0!./src/components/about-page.vue
 Module build failed: Error: "extract-text-webpack-plugin" loader is used 
 without the corresponding plugin, refer to 
 https://github.com/webpack/extract-text-webpack-plugin for the usage 
 example
     at Object.module.exports.pitch (D:\web\transport-
 serverSide\node_modules\extract-text-webpack-plugin\loader.js:25:9)
 @ ./src/components/about-page.vue 3:4-388
 @ ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?
 type=script&index=0!./src/components/Top.vue
 @ ./src/components/Top.vue
 @ ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?
 type=script&index=0!./src/components/Main.vue
 @ ./src/components/Main.vue
 @ ./src/router/index.js
 @ ./src/app.js
 @ ./src/entry-server.js

我如何设置webpack或者我可以上课吗?在Vue.js的官方网站上有关设置的信息不是很有用 也许我需要更改逻辑webpack.base.config? 如果有人可以帮助主题,或者ssr + express的主题 - 我将非常感激

0 个答案:

没有答案