Full build option?
Is there a way to perform a full build, so that I get a self-sufficient singular JS file?
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.
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 Thanks, It works.