webpack-serve在导入时抛出意外*

时间:2018-07-29 12:39:00

标签: webpack webpack-dev-server webpack-serve

为什么webpack-serve在导入*的第一行中意外抛出*? 但是,使用webpack-dev-server时,它没有问题。

我认为它不适用于TypeScript文件,但如果与JavaScript(.js)文件一起使用,则会引发相同的错误。

该错误抱怨webpack 4的以下配置中的第一行。

我有以下wpconfig.ts:

import * as MiniCssExtractPlugin from 'mini-css-extract-plugin'
import * as path from 'path'
import * as TailwindPlugin from 'tailwindcss'
import { VueLoaderPlugin } from 'vue-loader'
import {
  Configuration,
  HotModuleReplacementPlugin,
  NamedModulesPlugin
} from 'webpack'
import * as merge from 'webpack-merge'

let configuration = {
  context: path.resolve(__dirname),
  entry: path.resolve(__dirname, 'index.ts'),
  output: {
    path: path.resolve(__dirname, 'bundles'),
    filename: 'index.js'
  },
  resolve: {
    extensions: ['.js', '.ts'],
    alias: {
      framework7$: 'framework7/framework7.esm.bundle.js',
      vue$: 'vue/dist/vue.runtime.esm.js'
    }
  },
  module: {
    // loaders...
  },
  plugins: [
    new VueLoaderPlugin(),
    new MiniCssExtractPlugin({ filename: 'index.css' })
  ],
  devtool: 'source-map'
} as Configuration

if (process.env.NODE_ENV == 'production') {
  configuration = merge(configuration, { mode: 'production' })
} else {
  configuration = merge(configuration, {
    mode: 'development',
    plugins: [new NamedModulesPlugin(), new HotModuleReplacementPlugin()]
  })
}

export default configuration

有任何线索吗?

谢谢!

0 个答案:

没有答案