webpack-2

Webpack static website images cache busting

耗尽温柔 提交于 2019-12-08 08:53:56
问题 I'm using webpack-html-plugin to generate a one-page static website. I'm trying to implement cache busting for the static assets, images especially. I also have a meta tag for an open graph image, which is listed bellow. My webpack.config.js looks something along the lines of this: module.exports = { entry: './src/init.js', output: { path: './build', filename: 'bundle.js', }, module: { loaders: [{ test: /\.js?$/, exclude: /node_modules/, loader: 'babel-loader' }, { test: /\.(jpe?g|png|gif|svg

Trying to concatenate js files with webpack (like a gulp script)

為{幸葍}努か 提交于 2019-12-08 04:10:57
问题 I want to reproduce this Gulp script with webpack to have only one process who listen on files but i can't make it work. This is my Gulp task gulp.task('scripts', function(){ return gulp.src( WATCH_SCRIPTS.SCRIPTS ) .pipe(plumber()) .pipe(sourcemaps.init()) .pipe(concat('plugins.min.js')) .pipe(babel({ compact: false, babelrc: false, presets: ['es2015-allow-top-level-this'] })) .pipe(ifElse(PROD_ENV, () => {return uglify({ hoist_vars: true, global_defs: { jQuery: false, $: false, } })}, () =>

Declaration Merging not Working in Angular 2 Project

China☆狼群 提交于 2019-12-07 23:49:16
问题 I am trying to implement a custom RxJS operator as described in this answer. Here are the relevant snippets in my application: rxjs-extensions.ts import { Observable } from 'rxjs/Observable'; function restrictToCommand<T>(this: Observable<T>): Observable<T> { console.log('works'); return Observable.empty() } declare module 'rxjs/Observable' { interface Observable<T> { restrictToCommand: typeof restrictToCommand; } } Observable.prototype.restrictToCommand = restrictToCommand; consumer.ts

Optimize Angular vendor output

*爱你&永不变心* 提交于 2019-12-07 22:52:53
问题 In trying to optimize the vendor bundle when building with webpack, I'm using the NgcWebpackPlugin. This is the vendor bundle visually presented: What surprises me is the presence of the angular compiler module even tho we are utilizing AOT. Do I need to somehow explicitly declare that I don't need the compiler in the bundle? Or am I missing something else? Here's the vendor.ts : import '@angular/platform-browser'; import '@angular/platform-browser-dynamic'; import '@angular/core'; import '

Webpack + React router dynamic routing - how to catch require loading exception with require.ensure

☆樱花仙子☆ 提交于 2019-12-07 11:48:10
问题 I'm using the react/react-router/webpack stack with dynamic routing between my different pages of the app which means every page loads asynchronously by demand. Everything works great but when I deploy a new version, my current active users who didn't fetch all of the Js file of all the pages will get stuck once the'll try to navigate to another page they haven't visited yet. EXAMPLE lets say I have a code split app with the following .js generated files and md5 (for cache busting): main.123

Uncaught ReferenceError: $ is not defined Webpack and embedded script

与世无争的帅哥 提交于 2019-12-07 11:15:52
问题 I am using webpack to create a *.js bundle var path = require('path'); var webpack = require('webpack'); const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { entry: { site: [ './wwwroot/js/site.js', './node_modules/jquery/dist/jquery.js', './Scripts/jquery.global.js', './node_modules/jquery-validation/dist/jquery.validate.js', './node_modules/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js', './node_modules/popper.js/dist/popper.js', './node

Loading jQuery plugins with webpack 2

家住魔仙堡 提交于 2019-12-07 09:22:37
问题 After spending most of the day googling and trying - i did not get it to work and at this point i'm not sure what's missing. I already have jQuery working (and verified it works) in webpack.common.js: new ProvidePlugin({ jQuery: 'jquery', $: 'jquery', jquery: 'jquery' }) For example i have a "MetisMenu" plugin, where should i configure it? I tried various combinations of require/include in my app.module.ts. Like (including assigning them to a constant/var but import/require always give this

jQuery with Webpack 2

拥有回忆 提交于 2019-12-07 07:51:19
问题 My webpack.config.js looks as below : var debug = process.env.NODE_ENV !== "production"; var webpack = require('webpack'); var path = require('path'); var node_dir = __dirname + '/node_modules'; const autoprefixer = require('autoprefixer'); const ProvidePlugin = require('webpack/lib/ProvidePlugin'); module.exports = { context: path.join(__dirname, "src"), devtool: debug ? "inline-sourcemap" : null, entry: ['tether', 'font-awesome-loader',"bootstrap-loader","./js/client.js"], resolve: {

Handling config files with webpack

社会主义新天地 提交于 2019-12-07 00:37:02
问题 I have an electron app that I'm building with webpack 2. I have a config file that I'm including like a normal webpack resource: config.js: export default { config1: 1, config2: 2 } main.js: import config from '../some/path/config'; console.log(config.config1); The config file code ends up in my bundle.js file as you would expect. The problem is that the point of config files is that you can change them after deployment. This set up requires me to re-webpackify everything if I want config

How to fix “@types/node/index.d.ts is not a module”?

不羁的心 提交于 2019-12-06 22:41:40
问题 I have installed node type definitions using the following command npm install --save-dev @types/node After that, when I try to import the node type definitions using the following statement import { Process } from '@types/node'; or import { Process } from 'node'; I get the following error [ts] File '<root_path>/node_modules/@types/node/index.d.ts' is not a module. I am sure there is something very basic that I am missing here but I cannot figure out. Few more things I am using Windows 8 I am