【问题标题】:webpack typescript configuration template and style need a loaderwebpack typescript 配置模板和样式需要一个loader
【发布时间】:2020-07-29 22:49:50
【问题描述】:

我已经使用 Webpack 和 typescript 从头开始​​配置了一个 Vue 项目,但不明白为什么在我的 .vue 文件中添加 <template> 元素和使我的 webpack 观察程序显示错误的 <style> 元素时出现错误

这是错误:

这是我的 webpack.config.js 文件:

var path = require('path')
var webpack = require('webpack')

module.exports = {
  entry: './src/index.ts',
  output: {
    path: path.resolve(__dirname, './dist'),
    publicPath: '/dist/',
    filename: 'build.js'
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
            'scss': 'vue-style-loader!css-loader!sass-loader',
            'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax',
          }
        }
      },
      {
        test: /\.tsx?$/,
        loader: 'ts-loader',
        exclude: /node_modules/,
        options: {
          appendTsSuffixTo: [/\.vue$/],
        }
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        loader: 'file-loader',
        options: {
          name: '[name].[ext]?[hash]'
        }
      }
    ]
  },
  resolve: {
    extensions: ['.ts', '.js', '.vue', '.json'],
    alias: {
      'vue$': 'vue/dist/vue.esm.js'
    }
  },
  devServer: {
    historyApiFallback: true,
    noInfo: true
  },
  performance: {
    hints: false
  },
  devtool: '#eval-source-map'
}

【问题讨论】:

    标签: typescript vue.js webpack


    【解决方案1】:

    如果有人遇到同样的问题,那是因为我使用的版本是vue-loader,我使用的是 v15,我需要 14 个

    【讨论】:

      猜你喜欢
      • 2015-08-15
      • 2018-03-19
      • 1970-01-01
      • 2016-06-14
      • 1970-01-01
      • 2016-03-19
      • 2016-10-28
      • 2017-08-10
      • 2016-01-12
      相关资源
      最近更新 更多