0

I'm trying to build an LWC OSS project for production, but I can't figure out where the 'npm run build' command builds the bundled resource. I don't see anything obvious in the configs or on either of these sites

https://github.com/muenzpraeger/create-lwc-app/blob/main/packages/lwc-services/example/lwc-services.config.js https://www.npmjs.com/package/@lwc/compiler

I'm using the default settings and I think it must be something here in the lwc-services.config.js

lwcCompilerOutput: {
    production: {
        compat: false,
        minify: true,
        env: {
            NODE_ENV: 'production'
        }
    }
}

can I specify a file name and location and what is the default file name and location?

1

The default directory is "dist", but you can change this. Find your project.json file, and locate this section:

"scripts": {
    "build": "lwc-services build -m production",

And add the desired destination to the command:

"scripts": {
    "build": "lwc-services build -m production -d prod",

Where prod is the desired output directory.

Depending on what you're doing, you may need to update additional scripts, as they presume that dist is the source for your production build.

2
  • cool thanks, I see two files in there app.js and 0.app.js do you know what the difference is? Oct 19 '20 at 14:48
  • 1
    @ScottMorrison 0.app.js is the LWC runtime, app.js is your main app component's JavaScript. Both are necessary for LWC OSS to run.
    – sfdcfox
    Oct 19 '20 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.