webpack-dev-server

How to add a js file with webpack?

点点圈 提交于 2020-01-11 04:41:35
问题 I was reading this webpack tutorial: https://webpack.github.io/docs/usage.html It says it bundles the src files and node_modules. If I want to add another .js file there, how can I do this? This is a thirdpartyjs file that is not part of the source and not part of the node_modules files. This is my current webpack.config.js: var path = require('path'); var webpack = require('webpack'); module.exports = { entry: [ 'react-hot-loader/patch', 'webpack-dev-server/client?http://localhost:8080',

webpack4的配置你都掌握了么?

别说谁变了你拦得住时间么 提交于 2020-01-08 10:56:12
webpack5都出了,webpack4的的基本配置,解析ES6,引入CSS,编译Less,设置image等等,你都会了么? ​解析ES6 了解Babel Babel是一个JavaScript编译器,可以实现将ES6+转换成浏览器能够 识别的代码。 Babel在执行编译时,可以依赖.babelrc文件,当设置依赖文件时, 会从项目的根目录下读取 .babelrc 的配置项,.babelrc配置文件 主要是对 预设(presets) 和 插件(plugins) 进行配置。 其中,presets可以标识需要转换的源码使用了哪些新特性, 可以理解为一系列plugins的集合,例如babel-preset-es2015,可以 将es6转换为es5;而plugins则指示babel如何对代码进行转换, 例如plugin-transform-arrow-functions可将ES6语法转换为 ES5。 解析ES6 1、安装依赖 npm i @babel/core @babel/preset-env babel-loader -D 2、配置webpack.config.js设置loader module: { rules: [ { test: /.js$/, use: 'babel-loader' } ] } 3、根目录创建.babelrc,并配置preset-env对ES6+语法特性进行转换

Using a simple vue.js/webpack setup, how does one configure the dev server to proxy everything EXCEPT a few .js and .vue files?

给你一囗甜甜゛ 提交于 2020-01-07 03:37:10
问题 So some quick background on the site's current setup: My company's site currently runs off of a CMS. All pages are generated and routed via the CMS, so there are no .html files anywhere. It's all generated via razor (.cshtml), the CMS as a backend/data-store, and routing is handled through the CMS. If it were up to me I'd rewrite the entire thing, but I don't have that luxury. I'm doing my best to rewrite the site with a Vue.js + webpack front-end wherever possible and slowly rebuild this

Why is webpack-dev-server throwing an error when I use --arg?

浪子不回头ぞ 提交于 2020-01-06 07:57:01
问题 This is my script: "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --arg devus" In my old setup I used to do: "dev": "node build/dev-server.js --arg dev" How can I achieve the same (having the --arg dev thing) with webpack-dev-server ? This is the error: Unknown argument: arg npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! test-phantom@1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --arg devus` 回答1: The thing you

Why is webpack-dev-server throwing an error when I use --arg?

亡梦爱人 提交于 2020-01-06 07:55:08
问题 This is my script: "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --arg devus" In my old setup I used to do: "dev": "node build/dev-server.js --arg dev" How can I achieve the same (having the --arg dev thing) with webpack-dev-server ? This is the error: Unknown argument: arg npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! test-phantom@1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --arg devus` 回答1: The thing you

webpack bundle fails on reload?

被刻印的时光 ゝ 提交于 2020-01-06 05:34:16
问题 I think the problem is not with react router configuration but my index.html not being able to detect my script? This is my error: Failed to load resource: the server responded with a status of 404 (Not Found) this is my webpack config code: const compiler = webpack({ entry: ['whatwg-fetch', path.resolve(__dirname, 'js', 'index.js')], module: { loaders: [ { exclude: /node_modules/, loader: 'babel-loader', test: /\.js$/, }, { test: /\.css$/, loaders: ['style-loader', 'css-loader'] } ], },

react 基础篇 #2 create-react-app

浪子不回头ぞ 提交于 2020-01-06 00:27:43
1. 介绍 在开发react应用时,应该没有人用传统的方法引入react的源文件(js),然后在html编辑吧。 大家都是用webpack + es6来结合react开发前端应用。 这个时候,我们可以手动使用npm来安装各种插件,来从头到尾自己搭建环境。 比如: npm install react react-dom --save npm install babel babel-loader babel-core babel-preset-es2015 babel-preset-react --save npm install babel webpack webpack-dev-server -g 复制代码 虽然自己搭建的过程也是一个很好的学习过程,但是有时候难免遇到各种问题,特别是初学者,而且每次开发一个新应用,都要自己从头搭建,未免太繁琐。 于是,有人根据自己的经验和最佳实践,开发了脚手架,避免开发过程中的重复造轮子和做无用功,从而节省开发时间。 类似这样的脚手架,我扫了网络上比较多人用和关注的,一共发现了三个,它们分别是: react-boilerplate react-redux-starter-kit create-react-app 它们的关注量都非常大,截至写这篇文章为止,在github上的star量是这样的: 由此可见,使用这三个脚手架的人都相当多,最突出的是

Webpack react-hot-loader not working

三世轮回 提交于 2020-01-05 08:58:10
问题 Below is my webpack.config.js code var webpack = require('webpack'); var path = require('path'); module.exports = { // context: __dirname + "/app", entry: [ 'webpack-dev-server/client?http://0.0.0.0:8080', 'webpack/hot/only-dev-server', './src/main.jsx'], output: { path: "./build", filename: "main.js" }, module: { loaders: [ { test: /\.jsx?$/, exclude: /(node_modules|bower_components)/, loaders: ['react-hot', 'babel'], include: path.join(__dirname, 'build'), query: { presets:['es2015', 'react

Configure Webpack to resolve relative paths

两盒软妹~` 提交于 2020-01-05 08:52:42
问题 I am trying to implement Material Web Components into my Web App as per Material Component Web's Getting Started Guide. I was able to successfully set up Webpack (V3) to load the SASS for a web component. This was after running into a problem with the include path. I was able to resolve this by adding this line to my webpack.config.js . { loader: 'sass-loader', options: { includePaths: ['./node_modules'] } } However, I wasn't as successful compiling the JS. The component in question is

Why does angular2-webpack-starter work with:' localhost:3000/#/', but Not with 'https://hostname/front/#/' WHY?

主宰稳场 提交于 2020-01-05 06:20:48
问题 I am using the 'angular2-webpack-stater' project and am ready to integrate with with my back end server. I setup nginx with two proxy-passes to connect to the front-end and the back-end: server { listen [::]:443 ssl; listen 443 ssl; server_name xxxxxxxxx.com; add_header Strict-Transport-Security "max-age=31536000; includeSubdomains"; root /var/www; index index.php index.html index.htm; autoindex off; rewrite_log on; location ^~ /server/ { proxy_set_header X-Real-IP $remote_addr; proxy_set