html-webpack-plugin

How do I add certain script tags inside <head> and <body> tags when using HtmlWebackPlugin

烂漫一生 提交于 2019-12-31 16:39:12
问题 I'm using HtmlWebpackPlugin to generate HTML files with javascript. Now I would like to add custom script at different parts of <head> and <body> tags Example: How do I, Add <script> alert('in head tag') </script> inside the <head> tag as the first child Add <script> alert('in body tag') </script> inside the <body> tag as the first child Here is the snippet in my Webpack config new HtmlWebpackPlugin({ hash: true, chunks: ["app"], filename: path.resolve(__dirname, "./public/pages/app.html"),

import CSS and JS files using Webpack

百般思念 提交于 2019-12-30 04:05:13
问题 I have a directory structure like this: and inside node_modules: >node_modules >./bin >webpack.config.js >bootstrap >bootstrap.css >bootstrap.js I need to generate separate CSS and JS bundles like this: custom-styles.css, custom-js.js, style-libs.css, js-libs.js where style-libs and js-libs should contain syles and js files of all libraries like bootstrap and jQuery. Here's what I have done so far: webpack.config.js: const path = require('path'); const basedir = path.join(__dirname, '../..

Flask can't find static files with webpack [duplicate]

非 Y 不嫁゛ 提交于 2019-12-24 09:27:14
问题 This question already has answers here : How to serve static files in Flask (16 answers) Link to Flask static files with url_for (2 answers) Closed last year . I'm currently creating a project involving flask and webpack. Currently the flask server is able to find the revelant template, but is not able to find the relevant JavaScript. I have a webpack config for creating the HTML file using the webpack html plugin like so: const path = require('path'); const HtmlWebpackPlugin = require('html

Webpack 4.36.1 not working with html-webpack-externals-plugin

与世无争的帅哥 提交于 2019-12-24 07:41:04
问题 I am migrating a library from webpack 1 to webpack 4. Which is to be consumed by another application with webpack 3. My libraries index.js looks like this, import * as config from './config'; export default class Helper{ constructor(options) { this.configurePaths({assetPath: options.assetPath || ''}); } configurePaths(configuration) { config.assetPath = configuration.assetPath || config.assetPath; } ... } Webpack of the library has: const path = require('path'); const env = require('yargs')

Webpack 2 - Suppress chunk files

可紊 提交于 2019-12-24 06:04:44
问题 As we are putting this output on a load balancer (not using sticky), we need to place the output of these files without chunks (neither hashes). These are the main two files for webpack configuration. webpack.common.js const path = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const helpers = require('./helpers'); const STATIC_TRANSLATION_MAP = require('..

Html-Webpack-Plugin Template: Module build failed: SyntaxError: Unexpected token

浪子不回头ぞ 提交于 2019-12-23 20:14:16
问题 When I try to build with html-webpack-plugin using index.ejs template file throws following error: Even if I try to load as .html file or install the ejs-loader, still fails. I am not sure if ejs-loader is installing with html-webpack-plugin. Some other people had the same issue but, their webpack version is @1 and the solution on that link did not worked for me., https://github.com/jantimon/html-webpack-plugin/issues/273 ERROR in ./node_modules/html-webpack-plugin/lib/loader.js!./src/index

Webpack Uglify errors in CSS

亡梦爱人 提交于 2019-12-23 07:34:42
问题 Im stressed trying to make Uglify working with my project, previously I have used Uglify and was not giving problems but now I think that is SASS related. ERROR in ./~/css-loader!./~/sass-loader!./app/scss/global-header.scss Module build failed: TypeError: Cannot read property '4' of undefined at reduce (/Users/contractor/centralefcom-global-components/node_modules/postcss-reduce-transforms/dist/index.js:121:23) at walk (/Users/contractor/centralefcom-global-components/node_modules/postcss

Webpack Uglify errors in CSS

﹥>﹥吖頭↗ 提交于 2019-12-23 07:34:06
问题 Im stressed trying to make Uglify working with my project, previously I have used Uglify and was not giving problems but now I think that is SASS related. ERROR in ./~/css-loader!./~/sass-loader!./app/scss/global-header.scss Module build failed: TypeError: Cannot read property '4' of undefined at reduce (/Users/contractor/centralefcom-global-components/node_modules/postcss-reduce-transforms/dist/index.js:121:23) at walk (/Users/contractor/centralefcom-global-components/node_modules/postcss

How to load images through webpack when using HTMLWebpackPlugin?

老子叫甜甜 提交于 2019-12-20 17:26:11
问题 I am using HTMLWebpackPlugin and in my template I have an img tag: <img src="./images/logo/png"> If you notice, here I am using a relative path thinking webpack will trigger the file loader that's configured in my webpack.config.js file but after compilation I get the exact same src attribute in my html: <img src="./images/logo/png"> How can I trigger webpack to dynamically replace these relative paths with, well whatever I've configured in my webpack configuration? 回答1: I'm not a webpack

Webpack, html-webpack-plugin, Error: Child compilation failed

自古美人都是妖i 提交于 2019-12-20 10:40:00
问题 I 've got a problem with my webpack configuration. After implementing html-webpack-plugin I got an Error, there's whole error stack from generated index.html . Error Stack: Html Webpack Plugin: Error: Child compilation failed: Conflict: Multiple assets emit to the same filename index.html: Error: Conflict: Multiple assets emit to the same filename index.html compiler.js:76 [Pre-build]/[html-webpack-plugin]/lib/compiler.js:76:16 Compiler.js:291 Compiler. [Pre-build]/[webpack]/lib/Compiler.js