question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I know that this is not the ideal place for this… I’m having trouble running a webpack with babel-loader. Would you have a more complete example of a configured webpack? I was not successful, following the documentation.

My webpack:

module.exports = (env = { NODE_ENV: 'development' }) => {
  const prod = env.NODE_ENV === 'production';

  // eslint-disable-next-line no-console
  console.log(`MODE: ${prod ? 'PRODUCTION' : 'DEVELOPMENT'}`);

  return {
    entry: './src/index.tsx',
    output: {
      filename: '[name].[chunkhash].js',
      path: path.resolve(__dirname, 'dist'),
    },
    mode: prod ? 'production' : 'development',
    devtool: 'source-map',
    ...(prod
      ? {}
      : { devServer: { historyApiFallback: true, hot: true, hotOnly: true } }),
    plugins: [
      // HTML Template
      new HtmlWebpackPlugin({ template: './index.html' }),
      new Style9Plugin(),
      new MiniCssExtractPlugin(),
    ].filter(Boolean),
    resolve: {
      extensions: ['.tsx', '.ts', '.js'],
    },
    module: {
      rules: [
        {
          test: /\.([tj])sx?$/,
          use: [
            Style9Plugin.loader,
            {
              loader: 'babel-loader',
              options: {
                presets: [
                  ['@babel/preset-env', { targets: 'last 1 chrome version' }],
                  [
                    '@babel/preset-react',
                    {
                      // Removes the need to import React into JSX files
                      runtime: 'automatic',
                    },
                  ],
                  '@babel/preset-typescript',
                ],
                plugins: [
                  // Fast Refresh
                  !prod && require.resolve('react-refresh/babel'),
                ].filter(Boolean),
                cacheDirectory: true,
              },
            },
          ],
        },
        {
          test: /\.css$/i,
          use: [MiniCssExtractPlugin.loader, 'css-loader'],
        },
        {
          test: /\.(png|jpe?g|gif|woff2?|eot|otf|webp)$/i,
          use: 'file-loader',
        },
      ],
    },
  };
};

Error:

Captura de Tela 2020-12-28 às 22 30 14

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
johanholmerincommented, Dec 29, 2020

Was caused by incompatibility with Webpack 5. It should be fixed in 0.5.9.

0reactions
rodrigojcmellocommented, Dec 29, 2020

repo: https://github.com/rodrigojcmello/style9-webpack

I disabled the style9 settings in the webpack just to make the application run. I also commented on the use in “src / components / Button / index.tsx”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started - webpack
Webpack is used to compile JavaScript modules. Once installed, you can interact with webpack either from its CLI or API.
Read more >
Getting Started With Webpack - Smashing Magazine
An example is the sample package.json file below. Here, we use webpack to bundle the application without a configuration file:.
Read more >
All You Need to Know about Webpack in Examples - Medium
1. Simplest project and Webpack installation;; 2. Configuration file;; 3. Regenerate bundle on file save;; 4. Using webpack-dev-server ...
Read more >
A Beginner's Guide to Webpack - SitePoint
Learn the core concepts to help you get started with webpack, the popular static module bundler. We'll help you understand how webpack works ......
Read more >
Webpack Tutorial for Beginners: A Complete Step ... - CodeinWP
Read this webpack tutorial for beginners to learn your first steps in bundling and serving HTML/JavaScript in an optimal fashion.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found