backpack icon indicating copy to clipboard operation
backpack copied to clipboard

Full build option?

Open tomsseisums opened this issue 7 years ago • 3 comments

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

tomsseisums avatar Feb 15 '18 21:02 tomsseisums

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 avatar Feb 21 '18 22:02 torjue

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;
    }
}

torjue avatar Feb 21 '18 23:02 torjue

@torjue Thanks, It works.

dvgamerr avatar Jan 29 '19 15:01 dvgamerr