Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack build error for second time #18267

Closed
CHENGCHANGHU opened this issue Apr 2, 2024 · 1 comment
Closed

Webpack build error for second time #18267

CHENGCHANGHU opened this issue Apr 2, 2024 · 1 comment

Comments

@CHENGCHANGHU
Copy link

Webpack compiles success for the first time, but it fails for the second time. So is there any error in my webpack configuration? I doubt that it is caused by compiling before cleaning, but I have no idea to debug this.

Error Log

ERROR in ***/test-component/dist/js/index.9446941a1b782bc1ed07.js
1:77-84
[tsl] ERROR in ***/test-component/dist/js/index.9446941a1b782bc1ed07.js(1,78)
      TS2339: Property 'options' does not exist on type 'never'.
ts-loader-default_250a9bafcdad9644

ERROR in ***/test-component/dist/js/index.9446941a1b782bc1ed07.js
1:428-432
[tsl] ERROR in ***/test-component/dist/js/index.9446941a1b782bc1ed07.js(1,429)
      TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
ts-loader-default_250a9bafcdad9644

webpack 5.91.0 compiled with 2 errors in 3171 ms

Webpack Config

{
  devServer: {
    historyApiFallback: true,
    hot: true,
  },
  resolve: {
    modules: [resolve(__dirname, 'src'), 'node_modules'],
    extensions: ['.vue', '.ts', '.tsx', '.js', '.jsx', '.scss', '.css'],
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        use: [
          {
            loader: 'vue-loader',
          }
        ],
      },
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        use: [
          {
            loader: 'babel-loader',
            options: {
              presets: [
                [
                  '@babel/preset-env',
                  { modules: false }
                ],
              ]
            },
          },
        ],
      },
      {
        test: /\.tsx?$/,
        exclude: /node_modules/,
        use: [
          {
            loader: 'babel-loader',
            options: {
              presets: [
                [
                  '@babel/preset-env',
                  { modules: false }
                ],
              ]
            },
          },
          {
            loader: 'ts-loader',
            options: {
              context: join(__dirname, '..'),
              configFile: join(__dirname, '..', 'tsconfig.json'),
              appendTsSuffixTo: [/\.vue$/],
            },
          },
        ],
      },
      {
        test: /\.(sa|sc|c)ss$/i,
        use: [
          isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
          'css-loader',
          'postcss-loader',
          'sass-loader',
        ],
      },
    ],
  },
  plugins: [
    new webpack.ProgressPlugin(),
    new VueLoaderPlugin(),
    new MiniCssExtractPlugin({
      filename: 'css/[name].[contenthash].css',
    }),
  ],
}
{
  entry: {
    index: join(__dirname, 'src', 'index.ts'),
  },
  output: {
    clean: true,
    path: join(__dirname, 'dist'),
    filename: 'js/[name].[contenthash].js',
  },
  resolve: {
    alias: {
      '@': join(__dirname, 'src'),
    },
  },
  plugins: [],
}
@CHENGCHANGHU
Copy link
Author

webpack --color --node-env=production --mode production -c ./webpack.config.mjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant