webpack-2

How can I share webpack.config snippets between projects?

谁都会走 提交于 2019-12-11 02:35:52
问题 I have several webpack configurations with very similar webpack.config files. I like to put webpack.config parts in a shared module that (I include the shared module with "npm link"), but that doesn't work as can't find dependencies, like "webpack" as it's the first dependency it encounters. 17 07 2017 14:49:32.694:ERROR [config]: Invalid config file! Error: Cannot find module 'webpack' at Function.Module._resolveFilename (module.js:470:15) First webpack.config lines: const webpack = require(

Async Code Splitting Webpack - Unexpected Token

Deadly 提交于 2019-12-11 01:07:11
问题 I was just following this guide I have this code: import React, { PropTypes, Component } from 'react'; import('contact-page').then(() => {}); I get this output: This is my webpack file: var webpack = require('webpack'); var packages = require('./package.json'); var path = require('path'); var ExtractTextPlugin = require("extract-text-webpack-plugin"); var HtmlWebpackPlugin = require('html-webpack-plugin'); var filterDependencies = ['normalize.css', 'font-awesome']; var dependencies = Object

webpack jquery and angular - jQuery not defined

孤街浪徒 提交于 2019-12-11 00:17:47
问题 I'm refactoring an existing project into webpack. The project uses angular (1.3) and jQuery (2.1). On the initial web page there are already some jQuery functions being called but these fail because 'jQuery is not defined'. Even after loading the page (via console) jQuery stays undefined. '$' is defined but I'm not sure if it's actually pointing to jQuery. I adapted the webpack config to expose the jquery variables in all modules (as explained here and in several posts): new webpack

How to set [name] of output.chunkFilename to be the same with [name] of output.filename?

こ雲淡風輕ζ 提交于 2019-12-11 00:16:17
问题 In webpack 2 I defined output like this: module.exports.output = { filename: `js/[name].js`, chunkFilename: `js/[id].[name].js`, } When devServer starts, entry file is main.js as expected. However, the chunk file is requested as 0.0.js , what should I do if I want 0.main.js ? Also I'm curious why can't chunkFilename's [name] be in accord with filename's [name]? 来源: https://stackoverflow.com/questions/44504783/how-to-set-name-of-output-chunkfilename-to-be-the-same-with-name-of-output-f

Angular CLI outputs the font-awesome font files the dist root

你离开我真会死。 提交于 2019-12-10 23:35:59
问题 Do you have to eject your angular-cli and override the webpack configuration in order to place the font-awesome fonts into the assets/fonts folder? I have this angular-cli and I include the font-awesome this way in my angular-cli.json : "styles": [ "styles.css", "../node_modules/bootstrap/dist/css/bootstrap.min.css", "../node_modules/font-awesome/css/font-awesome.min.css" ], but when I do ng build --prod I get everything built correctly however all font-awesome fonts are located in the root

How to get ngtemplate-loader working with Webpack 3, Angular 1, TypeScript and ES 6 modules?

五迷三道 提交于 2019-12-10 23:15:06
问题 I am trying configure ngtemplate-loader to be able to use my angular template in a TypeScript file like so: import myTemplateUrl from './hello-angular2-template.thtml'; angular .module('pd') .component('helloAngular2', { templateUrl: myTemplateUrl, }); Loader definition in webpack.config: module: { rules: [ // Angular Template HTML { test: /\.thtml$/, use: [ { loader: 'ngtemplate-loader', }, { loader: 'html-loader', } ], }, (The strange *.ththml suffix is just so, that no standard html-loader

react-share util.inherits is not a function webpack 2

て烟熏妆下的殇ゞ 提交于 2019-12-10 19:14:01
问题 i have the next error when i try to include react-share in my app, all compile fine and if i go to another routes where no is loading this library works fine, but when i include it crash. TypeError: util.inherits is not a function i am using webpack dev server with webpack 2. i am mocked the next modules note: i tried to mock utils so because util is not defined in not node env. node: { fs: "empty", child_process: "empty", }, 来源: https://stackoverflow.com/questions/43020296/react-share-util

Download a webpage in pdf format using angular4

99封情书 提交于 2019-12-10 18:37:07
问题 I am new for angular 4. I need to download a HTML webpage in pdf format and the html webpage contains angular controls like input [(ngModel)] , radio button [checked] . Rather than showing the control values it shows undefined in the pdf file. I tried using jsPdf & html2Pdf But it throws error Error: You need either https://github.com/niklasvh/html2canvas or https://github.com/cburgmer/rasterizeHTML.js at Object.jsPDFAPI.addHTML (jspdf.debug.js?6964:4049) Code for TS File: import { Component,

React: Load component's CSS only when component is rendered

我的未来我决定 提交于 2019-12-10 16:16:54
问题 # MyComponent.js import React from 'react' import './MyComponentStyle.css' export default class MyComponent extends React.Component { .... } # App.js import React from 'react' import ReactDOM from 'react-dom' import { Route, Switch, BrowserRouter } from 'react-router-dom' import MyComponent from './MyComponent' import PageNotFound from './PageNotFound' ReactDOM.render( <BrowserRouter> <Switch> <Route exact path='/mycomponent' component={MyComponent}/> <Route component={PageNotFound} /> <

Webpack-dev-server 2 Uncaught TypeError: util.inherits is not a function

橙三吉。 提交于 2019-12-10 15:21:58
问题 I have a problem trying when i run webpack-dev-server not console error in compilation time but throws the next error in browser when i go to http://localhost:8080/: Uncaught TypeError: util.inherits is not a function. is strange beacause works well with webpack without webpack-dev-server. when i debug the error the error is in file webpack:///./~/websocket-driver/lib/websocket/streams.js?875d and the error is this segment: var Stream = require('stream').Stream, util = require('util'); var IO