Webpack

How to set mode to development or production in the config file?

烂漫一生 提交于 2021-01-21 12:14:29
问题 We are migrating to webpack 4. We do have dev / prod config files already. We started getting this warning message: WARNING in configuration The 'mode' option has not been set. Set 'mode' option to 'development' or 'production' to enable defaults for this environment. We can get around this by passing --mode production in the cmdline like below: npm run webpack --mode development ... As is mentioned on the webpack documentation, blog and everywhere else on the internet. How can we set the

How to set mode to development or production in the config file?

血红的双手。 提交于 2021-01-21 12:14:08
问题 We are migrating to webpack 4. We do have dev / prod config files already. We started getting this warning message: WARNING in configuration The 'mode' option has not been set. Set 'mode' option to 'development' or 'production' to enable defaults for this environment. We can get around this by passing --mode production in the cmdline like below: npm run webpack --mode development ... As is mentioned on the webpack documentation, blog and everywhere else on the internet. How can we set the

Webpack style-loader / css-loader: url() path resolution not working

匆匆过客 提交于 2021-01-21 07:48:21
问题 There are a few SO posts about style-loader and css-loader , but despite this I have not been able to find a solution to my problem. In short summary, when I @import css files in other css files, and the imported css contains url() s with relative paths, the paths are not resolved correctly. Basically, the error message shows that Webpack ends up thinking the url() paths in the imported css are relative to src (main entry point), rather than being relative to the css file it it is imported

Is it possible to have html-webpack-plugin generate <style> elements from css?

▼魔方 西西 提交于 2021-01-21 07:32:11
问题 I have a static site where I am using Vue and Webpack. I have some global CSS rules in a file called style.css and I am importing them by using import './styles.css' from my index.js file. Additionally, I have some .vue files which generate their own CSS. To generate the HTML page, I am using html-webpack-plugin . My CSS rules appear to be applying correctly. However, the <style> tags which contain them are dynamically being added to the <head> of my page via the Javascript that Webpack

VueLoaderPlugin Error: No matching use for vue-loader is found

☆樱花仙子☆ 提交于 2021-01-21 06:52:58
问题 I am using webpack within a Laravel Mix project. When my webpack.config.js looks like this, Webpack works without error: module.exports = { module: { rules: [{ test: /\.vue$/, loader: 'vue-loader' }] } } But when I add VueLoaderPlugin like so: const VueLoaderPlugin = require('vue-loader/lib/plugin'); module.exports = { module: { rules: [{ test: /\.vue$/, loader: 'vue-loader' }] }, plugins: [ // make sure to include the plugin for the magic new VueLoaderPlugin() ] } I get this error: Error:

VueLoaderPlugin Error: No matching use for vue-loader is found

被刻印的时光 ゝ 提交于 2021-01-21 06:52:17
问题 I am using webpack within a Laravel Mix project. When my webpack.config.js looks like this, Webpack works without error: module.exports = { module: { rules: [{ test: /\.vue$/, loader: 'vue-loader' }] } } But when I add VueLoaderPlugin like so: const VueLoaderPlugin = require('vue-loader/lib/plugin'); module.exports = { module: { rules: [{ test: /\.vue$/, loader: 'vue-loader' }] }, plugins: [ // make sure to include the plugin for the magic new VueLoaderPlugin() ] } I get this error: Error:

Problems with babel loader in react-create-app

泪湿孤枕 提交于 2021-01-21 06:24:44
问题 The Problem create-react-app initializes a repository where babel-loader is installed as an older version than needed. LOG: There might be a problem with the project dependency tree. It is likely not a bug in Create React App, but something you need to fix locally. The react-scripts package provided by Create React App requires a dependency: "babel-loader": "8.0.4" Don't try to install it manually: your package manager does it automatically. However, a different version of babel-loader was

Using “npm run build” fails with “npm ERR! missing script: build”

徘徊边缘 提交于 2021-01-21 06:18:03
问题 How can i fix this error, I'm running Windows 10 When i try to npm run build on the cmd i get this error C:\Users\anai_> npm run build npm ERR! missing script: build Here is the log of the run 0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe', 1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'run', 1 verbose cli 'build' ] 2 info using npm@5.5.1 3 info using node@v9.1.0 4 verbose config Skipping project config:

Using “npm run build” fails with “npm ERR! missing script: build”

偶尔善良 提交于 2021-01-21 06:16:04
问题 How can i fix this error, I'm running Windows 10 When i try to npm run build on the cmd i get this error C:\Users\anai_> npm run build npm ERR! missing script: build Here is the log of the run 0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe', 1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'run', 1 verbose cli 'build' ] 2 info using npm@5.5.1 3 info using node@v9.1.0 4 verbose config Skipping project config:

TypeError: react__WEBPACK_IMPORTED_MODULE_2___default(…) is not a function. How do I solve this?

血红的双手。 提交于 2021-01-21 05:16:11
问题 I was using React when I got the following error. TypeError: react__WEBPACK_IMPORTED_MODULE_2___default(...) is not a function How do I solve this? I have added the code below. import React from 'react'; import LoginForm from './loginForm' import useState from "react" function LoginPage(){ const[details, setDetails] = useState({ username: '', password: '' }); function handleChange(event){ const updatedDetails = {...details, [event.target.name]: event.target.value}; setDetails(updatedDetails)