Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
Modify webpack config from cli in npm run

I'm developing an react.js application, where I provide the index.html file in the public directory, but use webpack to replace placeholders (<%= placeholder %>) in it. Currently, the target strings are provided by options.json, which looks like:

{
  "placeholder": "value"
}

I can make it work rudimentarily with the following entry in package.json and the following relevant parts of the webpack.config.js

"scripts": {
  "build": "webpack --config=webpack.config.js --env env=production"
}

and

var options = require('./options.json')
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  [...]
  plugins: [
    new HtmlWebpackPlugin({
      template: "public/index.html",
      templateParameters: options
    })
  ]
}

My goal would be to run npm run build <user_provided_options.json> so that I can switch between different versions of values for the placeholders. How can I achieve that?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!