question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Building features on demand

See original GitHub issue

What problem does this feature solve?

Build the application based on a set of a features instead of the current building environment.

I’m facing with a problem in the new @vue/cli. I want to create a staging environment for my company/application but I don’t find a nice way to do it without override lots of line of default webpack configuration file.

If I explicitly set the build mode (--mode staging), vue cli in fact gets the .env.staging environment variables BUT it builds the bundle with development features (for example, it doesn’t minify the code, it doesn’t extract the CSS, etc …)

Futhermore, if I build the bundle using this command, as the documentation recommends vue-cli-service build --mode development, it just not work without being served by internal vue dev-server. The static assets like images or icons are not being extracted out the bundle (I suppose this is intended behaviour) but my app.js is requesting images via HTTP that doesn’t exists in my distfolder.

What does the proposed API look like?

My proposal would be a way to abstract the core features available in @vue/cli to build against a set of required features instead of basing the build in the variable process.env.NODE_ENV

Of course, this behaviour can fallback in a pre-defined set of features by NODE_ENV if this list is not defined.

One example, vue.config.js:

...

webpackFeatures () {
    const features = [
      'pwa',
      'dll',
      'css-extract',
    ];
    
    if (process.env.NODE_ENV === 'production') {
      features.push('minification')
      features.push('css-purge')
    }
    
    return features
  }

...

If this becomes in something, in a future this could be a good approach to create plugins with features that encapsulate any webpack behaviour under a good readable name.

Of course, this is just a draft and the behaviour/api could change to adapt to the current code or whatever. I’m sure that I’m forgetting/not getting something into account, but I hope my idea is a bit more understandable.

Cheers.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
yyx990803commented, Mar 6, 2018

You are supposed to add

NODE_ENV=production

Into your .env.staging. As the doc explains:

  • mode !== env.
  • Only NODE_ENV=production will result in a production oriented build, regardless of mode.
  • Only production mode defaults to NODE_ENV=production. In any other mode, you need to explicitly set NODE_ENV to your desired value.
1reaction
LinusBorgcommented, Mar 6, 2018

If I explicitly set the build mode (--mode staging), vue cli in fact gets the .env.staging environment variables BUT it builds the bundle with development features (for example, it doesn’t minify the code, it doesn’t extract the CSS, etc …)

NODE_ENV=production vue-cli-service build --mode staging

…or set the NODE_ENV accordingly in the env file

Doesn’t that do what you want it to?

Futhermore, if I build the bundle using this command, as the documentation recommends vue-cli-service build --mode development, it just not work without being served by internal vue dev-server. The static assets like images or icons are not being extracted out the bundle (I suppose this is intended behaviour) but my app.js is requesting images via HTTP that doesn’t exists in my distfolder.

I don’t really understand this part.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Available features on demand | Microsoft Learn
Features on Demand (capabilities), introduced in Windows 10, are Windows feature packages that can be added at any time.
Read more >
On-Demand Service Delivery App: 12 Features Users Expect
12 Essential On-demand App Features That You Cannot Overlook in 2021. 1. Search and Filter; 2. Push Notifications; 3. Order Tracking; 4. Reviews...
Read more >
Developing an On-Demand Service App: Features, Costs, and ...
Basic features of an on-demand service app · Registration · Profiles · Maps · Real-time tracking · Filters · Shopping cart · Ratings...
Read more >
Must-have Features to build an on-demand home services app
An overview of the features · Registration · Payout method · Multiple languages and currencies · Booking visibility · Push notification · Cancellation ......
Read more >
Deploy Feature on Demand using SCCM
This blog post describe how to Deploy Windows 10 Feature on Demand using SCCM Current Branch with Script and/or Packages. SCCM Feature on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found