babel-loader jsx SyntaxError: Unexpected token [duplicate]

Add “babel-preset-react” npm install babel-preset-react and add “presets” option to babel-loader in your webpack.config.js (or you can add it to your .babelrc or package.js: http://babeljs.io/docs/usage/babelrc/) Here is an example webpack.config.js: { test: /\.jsx?$/, // Match both .js and .jsx files exclude: /node_modules/, loader: “babel”, query: { presets:[‘react’] } } Recently Babel 6 was released and … Read more

where is create-react-app webpack config and files?

If you want to find webpack files and configurations go to your package.json file and look for scripts You will find that scripts object is using a library react-scripts Now go to node_modules and look for react-scripts folder react-script-in-node-modules This react-scripts/scripts and react-scripts/config folder contains all the webpack configurations.

How to add fonts to create-react-app based projects?

There are two options: Using Imports This is the suggested option. It ensures your fonts go through the build pipeline, get hashes during compilation so that browser caching works correctly, and that you get compilation errors if the files are missing. As described in “Adding Images, Fonts, and Files”, you need to have a CSS … Read more

Passing environment-dependent variables in webpack

There are two basic ways to achieve this. DefinePlugin new webpack.DefinePlugin({ ‘process.env.NODE_ENV’: JSON.stringify(process.env.NODE_ENV || ‘development’) }), Note that this will just replace the matches “as is”. That’s why the string is in the format it is. You could have a more complex structure, such as an object there but you get the idea. EnvironmentPlugin new … Read more

How to bundle an Angular app for production

2 to 14 (TypeScript) with Angular CLI OneTime Setup npm install -g @angular/cli ng new projectFolder creates a new application Bundling Step ng build (run in command line when directory is projectFolder). flag prod bundle for production is now the default (see the Angular documentation to customize it if needed). Compress using Brotli compression the … Read more

What does the @ mean inside an import path?

This is done with Webpack resolve.alias configuration option and isn’t specific to Vue. In Vue Webpack template, Webpack is configured to replace @/ with src path: const path = require(‘path’); … resolve: { extensions: [‘.js’, ‘.vue’, ‘.json’], alias: { … ‘@’: path.resolve(‘src’), } }, … The alias is used as: import ‘@/<path inside src folder>’;

How to copy static files to build directory with Webpack?

Requiring assets using the file-loader module is the way webpack is intended to be used (source). However, if you need greater flexibility or want a cleaner interface, you can also copy static files directly using my copy-webpack-plugin (npm, Github). For your static to build example: const CopyWebpackPlugin = require(‘copy-webpack-plugin’); module.exports = { context: path.join(__dirname, ‘your-app’), … Read more

Getting Unexpected Token Export

Updated for 2022 You are using EcmaScript Module (ESM or ‘ES6 Modules’) syntax but your environment does not support it. NodeJS versions prior to v14.13.0 do not support ESM (export keyword syntax) and use CommonJS Modules (module.exports property syntax). NodeJS v14.13.0 and newer supports ESM but it must be enabled first. Solutions: If you are … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)