webpack-dev-server

Webpack how to build production code and how to use it

↘锁芯ラ 提交于 2019-12-17 08:00:15
问题 I am very new to webpack, I found that in production build we can able to reduce the size of overall code. Currently webpack builds around 8MB files and main.js around 5MB. How to reduce the size of code in production build? I found a sample webpack configurtion file from internet and I configured for my application and I run npm run build and its started building and it generated some files in ./dist/ directory. Still these files are heavy(same as development version) How to use these files?

What aspect of Hot Module Replacement is this article for?

白昼怎懂夜的黑 提交于 2019-12-14 03:48:34
问题 I am learning Webpack and come across this article. I have general idea of what is hot module replacement(HMR). I can configure webpack HMR plugin by following example code: var plugins = [ new webpack.HotModuleReplacementPlugin(), // using HMR plugin new HtmlWebpackPlugin({template: './index.html'}) ]; module.exports = { // webpack config object context: entryBasePath, entry:{ app: ['webpack/hot/dev-server', './bootstrap.js'] }, output: { path: outputBasePath, filename: './bundle.js',

“Unexpected token <” for VueJS running with Webpack

狂风中的少年 提交于 2019-12-13 17:57:22
问题 Note: Before you mark this as a duplicate , I have looked at a few solutions and they don't work: [1] https://github.com/webpack/webpack-dev-server/issues/135 [2] https://github.com/gaearon/react-hot-loader/blob/master/docs/Troubleshooting.md#syntax-error-unexpected-token- Few other Unexpected token < threads here but they are (probably) unrelated. I am trying to integrate VueJS into an OSS chat application https://github.com/zulip/zulip . I tried to use the standard configuration template

react-router-redux webpack dev server historyApiFallback fails

假如想象 提交于 2019-12-13 12:50:51
问题 After enabling historyApiFallback in the webpack config file and restarting the server, when changing location pathname, the browser refreshes, causing outer elements to re-mount (what I mean is that, I can see it flash white and back to normal) where this should only happen for nested the.props.children . In my particular case, there's a <Navbar /> element that is always present at the top and a container that has the { this.props.children } . I wonder what's going on? App entrypoint: import

npm ERR! missing script build

一世执手 提交于 2019-12-13 05:36:12
问题 I'm using Windows 10 and powershell, trying to run a webpack app cloned from my github. When I type npm run start I get: npm ERR! missing script: build; The build script is most definitely in my package.json: "scripts": { "build": "webpack --mode development", "start": "npm run build; webpack-dev-server --open", "lint": "eslint src/*.js", "test": "karma start karma.conf.js" }, When I'm on a mac, npm run start opens a local dev server just fine. Any ideas why I am unable to run this on my pc?

Webpack adding duplicates of runtime into bundle

被刻印的时光 ゝ 提交于 2019-12-13 04:33:31
问题 Does anyone know why I am getting duplicates of the webpack runtimes in the bundle? It's adding multiple numbers after the ? and the browser is seeing them as new files. dev-server.js? dev-server.js?52d4 dev-server.js?53d4* See the file tree on the left: Why is it doing this? I just want one copy of the file in the bundle. 回答1: Webpack sets up a client/server pair for each entry by design. That's why you are seeing all of those prints. Given each entry happens to depend on jwt-decode , you

Cannot go directly to dynamic route with react-router and webpack-dev-server

痴心易碎 提交于 2019-12-13 03:52:56
问题 After starting webpack-dev-server, I can go directly to a static route (e.g. http://localhost:3456/one ), but I cannot go directly to a dynamic route (e.g. http://localhost:3456/two/1234 ). I believe I am missing something in my webpack-dev-server config, but not sure what. The browser console outputs this error: GET http://localhost:3456/two/dev-bundle.js 404 (Not Found) Refused to execute script from 'http://localhost:3456/two/dev-bundle.js' because its MIME type ('text/html') is not

Webpacker/Typescript can't resolve rails asset pipeline file

房东的猫 提交于 2019-12-13 03:49:29
问题 I'm trying to import a file that is in the rails asset pipeline and for some reason webpack can't find it. Here is my tsconfig.json: { "compilerOptions": { "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": ["es6", "dom"], "module": "es6", "moduleResolution": "node", "sourceMap": true, "target": "es5", "baseUrl": ".", "paths": { "@images/*": ["app/assets/images/*"], } }, "exclude": [ "**/*.spec.ts", "node_modules", "vendor", "public" ], "compileOnSave"

TS2304 with Webpack 2 and Angular 2

江枫思渺然 提交于 2019-12-12 23:33:24
问题 I've been following angular's documentation on how to use webpack 2 with angular 2. My code (github src here) is set up up with the webpack.dev.js scenario. Running the dev build using npm start (i.e., webpack-dev-server --inline --progress --port 8080 ) gives a series of TS2304 errors, such as ERROR in [at-loader] src\app\app.component.ts:5:15 TS2304: Cannot find name 'require'. ERROR in [at-loader] src\app\app.component.ts:6:14 TS2304: Cannot find name 'require'. What is going wrong? 回答1:

Uncaught Error: Incompatible SockJS! - Angular 2 CLI

假装没事ソ 提交于 2019-12-12 19:18:01
问题 I have been getting the error: 'Uncaught Error: Incompatibile SockJS! Main site uses: "1.1.1", the iframe: "1.0.1".' I was not getting this error until I added the following code to a service: *COMPONENT* this.dataService.getData(1,null).subscribe( result => this.allSCATSsites = result.json(), () => console.log("Failed..."), () => this.processSites() ); *SERVICE* getData(functionindex: number, dataarray) { let headers = new Headers(); headers.append('Content-Type', 'application/json'); return