1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- const webpack = require('webpack');
- const path = require('path');
- const CopyWebpackPlugin = require('copy-webpack-plugin');
- const fs = require('fs');
- module.exports = {
- mode: process.env['BROWSH_ENV'] === 'RELEASE' ? 'production' : 'development',
- target: 'node',
- entry: {
- content: './content.js',
- background: './background.js'
- },
- output: {
- path: __dirname,
- filename: 'dist/[name].js',
- },
- resolve: {
- modules: [
- path.resolve(__dirname, './src'),
- 'node_modules'
- ]
- },
- devtool: 'source-map',
- plugins: [
- new webpack.DefinePlugin({
- DEVELOPMENT: JSON.stringify(true),
- TEST: JSON.stringify(false),
-
- PRODUCTION: JSON.stringify(false)
- }),
- new CopyWebpackPlugin([
- { from: 'assets', to: 'dist/assets' },
- { from: '.web-extension-id', to: 'dist/' },
- { from: 'manifest.json', to: 'dist/',
-
- transform(manifest, _) {
- const version_path = '../interfacer/src/browsh/version.go';
- let buffer = fs.readFileSync(version_path);
- let version_contents = buffer.toString();
- const matches = version_contents.match(/"(.*?)"/);
- return manifest.toString().replace('BROWSH_VERSION', matches[1]);
- }
- },
- ])
- ]
- };
|