Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full build option? #111

Open
tomsseisums opened this issue Feb 15, 2018 · 3 comments
Open

Full build option? #111

tomsseisums opened this issue Feb 15, 2018 · 3 comments

Comments

@tomsseisums
Copy link

Is there a way to perform a full build, so that I get a self-sufficient singular JS file?

@torjue
Copy link

torjue commented Feb 21, 2018

Adding the following to your backpack.config.js should do the trick. It removes source maps and bundles files from node_modules.

module.exports = {
    webpack: (config, options, webpack) => {
        config.devtool = false
        config.externals = []
        config.plugins.splice(1, 1)
        return config
    }
}

This it not an ideal solution, in my mind. As mentioned in #25, when running backpack in a dev environment, you want source maps to be there. When running in production, you no longer care about them. There is no reason to have massive dependencies like Babel and Webpack around for something you don't care about.

It would be better if you could install backpack with yarn add backpack-core --dev, and then let backpack build (maybe with an extra production argument?) build to a dist folder, without source maps. yarn install --production would then work as expected.

@torjue
Copy link

torjue commented Feb 21, 2018

const path = require('path');

module.exports = {
    webpack: (config, options, webpack) => {
        if (options.env === 'production') {
            config.devtool = false;
            config.plugins.splice(1, 1);
            config.output.path = path.join(process.cwd(), 'dist');
        }
        return config;
    }
}

@dvgamerr
Copy link

@torjue Thanks, It works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants