Skip to content

Commit

Permalink
Upgrade packages and support cleaning directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Acesmndr committed May 16, 2020
1 parent c6d0032 commit eef62f8
Show file tree
Hide file tree
Showing 4 changed files with 3,902 additions and 3,514 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ src/assets/css/main.css
src/background.js
yarn-error.log
coverage
key.pem
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"babel-preset-env": "^1.7.0",
"babel-preset-stage-0": "^6.24.1",
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^5.0.4",
"cross-env": "^5.2.0",
"copy-webpack-plugin": "^6.0.0",
"cross-env": "^7.0.2",
"crx": "^5.0.1",
"css-loader": "^3.2.0",
"glob": "^7.1.3",
Expand All @@ -40,14 +40,14 @@
"devDependencies": {
"@babel/preset-env": "^7.5.5",
"@riotjs/cli": "^4.0.2",
"babel-jest": "24.9.0",
"babel-jest": "^26.0.1",
"chai": "^4.2.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^24.9.0",
"jest-css-modules-transform": "^2.5.0",
"mocha": "^6.2.0",
"riot-jest-transformer": "^5.0.0",
"sinon": "^7.4.1",
"jest": "^26.0.1",
"jest-css-modules-transform": "^4.0.0",
"mocha": "^7.1.2",
"riot-jest-transformer": "^6.1.0",
"sinon": "^9.0.2",
"sinon-chrome": "^3.0.1"
},
"resolutions": {
Expand Down
67 changes: 38 additions & 29 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const glob = require('glob');
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const { registerPreprocessor } = require('@riotjs/compiler');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

Expand All @@ -22,35 +23,43 @@ const baseUrl = () => {
};
const packageJSON = require('./package.json');

const copyPlugin = new CopyWebpackPlugin([{
from: './src/background/images/',
to: 'img/',
}, {
from: './src/popup/images/',
to: 'img/',
}, {
from: './src/popup/index.html',
to: '../popup.html',
}, {
from: './src/background/index.html',
to: '../background.html',
}, {
from: './src/manifest.json',
transform: (content) => {
const manifestJSON = JSON.parse(content.toString());
return JSON.stringify(Object.assign({}, manifestJSON, { version: packageJSON.version }), null, ' ');
},
to: '../',
}]);
const copyPlugin = new CopyWebpackPlugin({
patterns: [
{
from: './src/background/images/',
to: 'img/',
}, {
from: './src/popup/images/',
to: 'img/',
}, {
from: './src/popup/index.html',
to: '../popup.html',
}, {
from: './src/background/index.html',
to: '../background.html',
}, {
from: './src/manifest.json',
transform: (content) => {
const manifestJSON = JSON.parse(content.toString());
return JSON.stringify(Object.assign({}, manifestJSON, { version: packageJSON.version }), null, ' ');
},
to: '../',
}
]
});
const cleanPlugin = new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ['dist', 'production', 'staging', 'build', 'development'],
root: __dirname,
verbose: false,
dry: false,
verbose: true,
cleanOnceBeforeBuildPatterns: ['../../dist', '../../production', '../../staging', '../../build', '../../development'],
dangerouslyAllowCleanPatternsOutsideProject: true,
});
const defineUrlPlugin = new webpack.DefinePlugin({ BASE_URL: JSON.stringify(baseUrl()) });
const uglifyPlugin = new UglifyJsPlugin({
uglifyOptions: {
comments: false, compress: { drop_console: ENV === 'production' }, minimize: true
const terserPlugin = new TerserPlugin({
terserOptions: {
comments: false,
compress: { drop_console: ENV === 'production' },
minimize: true,
exclude: /\.spec\.js$/,
},
});

Expand All @@ -68,7 +77,7 @@ module.exports = [{
},
plugins: [cleanPlugin, copyPlugin, defineUrlPlugin],
optimization: {
minimizer: [uglifyPlugin],
minimizer: [terserPlugin],
},
output: {
filename: '[name].js',
Expand Down Expand Up @@ -115,7 +124,7 @@ module.exports = [{
},
plugins: [defineUrlPlugin],
optimization: {
minimizer: [uglifyPlugin],
minimizer: [terserPlugin],
},
output: {
filename: '[name].js',
Expand Down
Loading

0 comments on commit eef62f8

Please sign in to comment.