webpack-dev-server

How to pass .env file variables to webpack config?

倾然丶 夕夏残阳落幕 提交于 2019-11-29 06:15:10
I am new to webpack and worked out almost all build sections, but now the problem is that I want to pass the environment variables from a .env file to webpack config, so that I can pass that variables to my build files via webpack.DefinePlugin plugin. Currently I am able to to pass environment variable directly from webpack to to my build. Please see the code below which I used in webpack. new webpack.DefinePlugin({ "API_URL": JSON.stringify("http://my-api.com"), "SECRET_KEY" : "MYSECRETKEYGOESHERE" }), My package.json build script is "scripts": { "start": "NODE_ENV=development webpack-dev

webpack-dev-server proxy dosen't work

…衆ロ難τιáo~ 提交于 2019-11-29 03:43:41
I want to proxy /v1/* to http://myserver.com , and here is my script devServer: { historyApiFallBack: true, // progress: true, hot: true, inline: true, // https: true, port: 8081, contentBase: path.resolve(__dirname, 'public'), proxy: { '/v1/*': { target: 'http://api.in.uprintf.com', secure: false // changeOrigin: true } } }, but it doesn't work, Update: thanks to @chimurai, setting changeOrigin: true is important to make it work. Underneath webpack-dev-server passes all the proxy configuration to http-proxy-middleware , from the documentation . It's clear the use case you want is actually

webpack dev server CORS issue

泪湿孤枕 提交于 2019-11-29 01:43:54
问题 I am using webpack-dev-server v1.10.1 to boost up my Redux project and I have the options below: contentBase: `http://${config.HOST}:${config.PORT}`, quiet: false, noInfo: true, hot: true, inline: true, lazy: false, publicPath: configWebpack.output.publicPath, headers: {"Access-Control-Allow-Origin": "*"}, stats: {colors: true} In the JS, I am using request from superagent to generate a HTTP GET call request .get(config.APIHost + apiUrl) .set('Accept', 'application/json') .withCredentials()

Why am I not being able to compile SASS with Webpack?

独自空忆成欢 提交于 2019-11-29 00:08:29
问题 I have the following modules in my Webpack config: module: { preLoaders: [ { test: /\.vue$/, loader: 'eslint', include: projectRoot, exclude: /node_modules/ }, { test: /\.js$/, loader: 'eslint', include: projectRoot, exclude: /node_modules/ } ], loaders: [ { test: /\.vue$/, loader: 'vue' }, { test: /\.js$/, loader: 'babel', include: projectRoot, exclude: /node_modules/ }, { test: /\.json$/, loader: 'json' }, { test: /\.html$/, loader: 'vue-html' }, { test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,

How to serve an Angular 2 dist folder index.html

非 Y 不嫁゛ 提交于 2019-11-28 20:20:07
I'm using this angular 4 seed app: https://github.com/2sic/app-tutorial-angular4-hello-dnn It uses webpack and works fine. It only seems to serve the dev files and not the dist/ folder. I want to ng serve the dist folder. Not sure the command to do this or if I need to install a lite server or something. I run this command to create the dist folder (which works fine): g build --prod --aot --output-hashing=none Now I want to run this build in the browser. You can use http-server for doing so. First of all generate a build using the command ng build --prod --aot --output-hashing=none . This will

Webpack-dev-server doesn't generate source maps

怎甘沉沦 提交于 2019-11-28 20:03:56
I use babel-loader , but can't figure out how to generate or where find source maps for transpiled files. I tried eval-source-map , inline-source-map , source-map . webpack.config.js const BowerWebpackPlugin = require("bower-webpack-plugin"); module.exports = { entry: './src/script/index.jsx', output: { filename: 'bundle.js', sourceMapFilename: "bundle.js.map", publicPath: 'http://localhost:8090/assets' }, debug: true, devtool: 'inline-source-map', module: { loaders: [ { test: /\.js[x]?$/, loaders: ['react-hot', 'jsx', 'babel'], exclude: /node_modules/ }, { test: /\.scss$/, loaders: [ 'style',

webpack-dev-server Cannot find module 'webpack'

青春壹個敷衍的年華 提交于 2019-11-28 17:23:42
问题 I'm trying to use webpack-dev-server to run a simple program but I'm getting this error: module.js:471 throw err; ^ Error: Cannot find module 'webpack' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module

Webpack-dev-server compiles files but does not refresh or make compiled javascript available to browser

家住魔仙堡 提交于 2019-11-28 17:19:34
问题 I'm trying to use webpack-dev-server to compile files and start up a dev web server. In my package.json I have the script property set to: "scripts": { "dev": "webpack-dev-server --hot --inline", } So the --hot and --inline should enable the webserver and the hot reloading (as I understand it). In my webpack.config.js file I set the entry, output, and devServer settings as well as add a loader to look for changes in .vue files: module.exports = { entry: './src/index.js', output: { path: _

Mocha testing failed due to css in webpack

匆匆过客 提交于 2019-11-28 17:08:46
I'm new to Mocha and I am trying to use it to test a simple React component. The test would pass if the react component doesn't have any CSS styling but throws a syntax error if the tag within the React component contains any className: Testing.react.js import React from 'react'; export default class Testing extends React.Component { render() { return ( <section> <form> <input type="text" /> </form> </section> ); } } testing.jsx import { React, sinon, assert, expect, TestUtils } from '../../test_helper'; import TestingSample from '../../../app/components/Testing.react.js'; describe(

Mocha tests don't run with Webpack and mocha-loader

扶醉桌前 提交于 2019-11-28 16:23:16
Background I am porting some npm scripts to Webpack loaders to better learn how Webpack works and I’ve got everything working except for my Mocha tests: I have one failing test, but it is not showing that Mocha is being run with the mocha-loader or that the test is failing: Question What do I need to do differently to get all src/**/*.test.js files to run with with Mocha in Webpack? Steps to reproduce Clone https://github.com/trevordmiller/webpack-loaders-playground Run npm test to see how tests should work Run npm run dev to see how tests don't run with Webpack Mocha loader won't run tests