refactor: rename TARGET to TARGET_BROWSER

This commit is contained in:
abhijithvijayan 2019-10-30 19:38:17 +05:30
parent dc47933a9a
commit 2f1248ce63
2 changed files with 13 additions and 11 deletions

View File

@ -8,12 +8,12 @@
"author": "abhijithvijayan <34790378+abhijithvijayan@users.noreply.github.com>", "author": "abhijithvijayan <34790378+abhijithvijayan@users.noreply.github.com>",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"dev:chrome": "cross-env NODE_ENV=development cross-env TARGET=chrome webpack --watch --mode=development", "dev:chrome": "cross-env NODE_ENV=development cross-env TARGET_BROWSER=chrome webpack --watch --mode=development",
"dev:firefox": "cross-env NODE_ENV=development cross-env TARGET=firefox webpack --watch --mode=development", "dev:firefox": "cross-env NODE_ENV=development cross-env TARGET_BROWSER=firefox webpack --watch --mode=development",
"dev:opera": "cross-env NODE_ENV=development cross-env TARGET=opera webpack --watch --mode=development", "dev:opera": "cross-env NODE_ENV=development cross-env TARGET_BROWSER=opera webpack --watch --mode=development",
"build:chrome": "cross-env NODE_ENV=production cross-env TARGET=chrome webpack --mode=production", "build:chrome": "cross-env NODE_ENV=production cross-env TARGET_BROWSER=chrome webpack --mode=production",
"build:firefox": "cross-env NODE_ENV=production cross-env TARGET=firefox webpack --mode=production", "build:firefox": "cross-env NODE_ENV=production cross-env TARGET_BROWSER=firefox webpack --mode=production",
"build:opera": "cross-env NODE_ENV=production cross-env TARGET=opera webpack --mode=production", "build:opera": "cross-env NODE_ENV=production cross-env TARGET_BROWSER=opera webpack --mode=production",
"build": "yarn run build:chrome && yarn run build:firefox && yarn run build:opera", "build": "yarn run build:chrome && yarn run build:firefox && yarn run build:opera",
"lint": "eslint .", "lint": "eslint .",
"lint:fix": "eslint . --fix" "lint:fix": "eslint . --fix"

View File

@ -7,6 +7,8 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries'); const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries');
const targetBrowser = process.env.TARGET_BROWSER;
module.exports = { module.exports = {
mode: 'development', mode: 'development',
@ -19,7 +21,7 @@ module.exports = {
output: { output: {
filename: 'js/[name].bundle.js', filename: 'js/[name].bundle.js',
path: path.resolve(__dirname, 'extension', process.env.TARGET), path: path.resolve(__dirname, 'extension', targetBrowser),
}, },
plugins: [ plugins: [
@ -27,8 +29,8 @@ module.exports = {
new FixStyleOnlyEntriesPlugin({ silent: true }), new FixStyleOnlyEntriesPlugin({ silent: true }),
new CleanWebpackPlugin({ new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [ cleanOnceBeforeBuildPatterns: [
path.join(process.cwd(), `extension/${process.env.TARGET}`), path.join(process.cwd(), `extension/${targetBrowser}`),
path.join(process.cwd(), `extension/${process.env.TARGET}.zip`), path.join(process.cwd(), `extension/${targetBrowser}.zip`),
], ],
cleanStaleWebpackAssets: false, cleanStaleWebpackAssets: false,
verbose: true, verbose: true,
@ -36,7 +38,7 @@ module.exports = {
new CopyWebpackPlugin([ new CopyWebpackPlugin([
{ from: 'src/assets', to: 'assets' }, { from: 'src/assets', to: 'assets' },
{ {
from: `src/manifests/${process.env.TARGET}.json`, from: `src/manifests/${targetBrowser}.json`,
transform(content, path) { transform(content, path) {
// generates the manifest file using the package.json informations // generates the manifest file using the package.json informations
return Buffer.from( return Buffer.from(
@ -128,7 +130,7 @@ module.exports = {
}), }),
new ZipPlugin({ new ZipPlugin({
path: path.resolve(__dirname, 'extension'), path: path.resolve(__dirname, 'extension'),
filename: `${process.env.TARGET}.zip`, filename: `${targetBrowser}.zip`,
}), }),
], ],
}, },