Skip to content
Snippets Groups Projects
Commit b636f9b8 authored by Jure's avatar Jure
Browse files

chore: webpack and babel fixes

parent 025694c5
No related branches found
No related tags found
No related merge requests found
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-import-meta",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-json-strings",
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions"
]
}
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: [
'babel-plugin-styled-components',
'@babel/plugin-proposal-class-properties',
],
}
...@@ -7,9 +7,9 @@ module.exports = [ ...@@ -7,9 +7,9 @@ module.exports = [
/pubsweet-[^/\\]+\/(?!node_modules)/, /pubsweet-[^/\\]+\/(?!node_modules)/,
/@pubsweet\/[^/\\]+\/(?!node_modules)/, /@pubsweet\/[^/\\]+\/(?!node_modules)/,
/xpub-[^/\\]+\/(?!node_modules)/, /xpub-[^/\\]+\/(?!node_modules)/,
/wax-[^/\\]+\/(?!node_modules)/, // /wax-[^/\\]+\/(?!node_modules)/,
// include other packages when this repo is mounted in a workspace // include other packages when this repo is mounted in a workspace
/components\/client\/[^/\\]+\/(?!node_modules)/, // /components\/client\/[^/\\]+\/(?!node_modules)/,
/packages\/[^/\\]+\/(?!node_modules)/, // /packages\/[^/\\]+\/(?!node_modules)/,
/node_modules\/xpub-edit/, /node_modules\/xpub-edit/,
] ]
...@@ -7,16 +7,8 @@ module.exports = [ ...@@ -7,16 +7,8 @@ module.exports = [
test: /\.js$|\.jsx$/, test: /\.js$|\.jsx$/,
loader: 'babel-loader', loader: 'babel-loader',
query: { query: {
presets: [ presets: [['@babel/preset-env'], '@babel/preset-react'],
['@babel/preset-env', { modules: false }], plugins: [require.resolve('react-hot-loader/babel')],
'@babel/preset-react',
],
plugins: [
'babel-plugin-styled-components',
require.resolve('react-hot-loader/babel'),
'@babel/plugin-proposal-class-properties',
// 'transform-decorators-legacy',
],
env: { env: {
production: { production: {
/* bug requires mangle:false https://github.com/babel/minify/issues/556#issuecomment-339751209 */ /* bug requires mangle:false https://github.com/babel/minify/issues/556#issuecomment-339751209 */
...@@ -39,39 +31,39 @@ module.exports = [ ...@@ -39,39 +31,39 @@ module.exports = [
], ],
}, },
{ test: /\.html$/, loader: 'html-loader' }, { test: /\.html$/, loader: 'html-loader' },
{ // {
test: /\.css$|\.scss$/, // test: /\.css$|\.scss$/,
exclude: /\.local\.s?css$/, // Exclude local styles from global // exclude: /\.local\.s?css$/, // Exclude local styles from global
loader: [ // loader: [
{ // {
loader: 'style-loader', // loader: 'style-loader',
}, // },
{ // {
loader: 'css-loader', // loader: 'css-loader',
}, // },
], // ],
}, // },
{ // {
test: /\.css$|\.scss$/, // test: /\.css$|\.scss$/,
include: /\.local\.s?css/, // Local styles // include: /\.local\.s?css/, // Local styles
loader: [ // loader: [
{ // {
loader: 'style-loader', // loader: 'style-loader',
}, // },
{ // {
loader: MiniCssExtractPlugin.loader, // loader: MiniCssExtractPlugin.loader,
options: { // options: {
hmr: process.env.NODE_ENV === 'development', // hmr: process.env.NODE_ENV === 'development',
}, // },
}, // },
{ // {
loader: 'css-loader', // loader: 'css-loader',
options: { // options: {
modules: true, // modules: true,
importLoaders: 1, // importLoaders: 1,
localIdentName: '[name]_[local]-[hash:base64:8]', // localIdentName: '[name]_[local]-[hash:base64:8]',
}, // },
}, // },
], // ],
}, // },
] ]
...@@ -63,7 +63,7 @@ module.exports = (opts = {}) => { ...@@ -63,7 +63,7 @@ module.exports = (opts = {}) => {
new webpack.optimize.AggressiveMergingPlugin(), new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(), new webpack.optimize.OccurrenceOrderPlugin(),
new CompressionPlugin(), new CompressionPlugin(),
new BundleAnalyzerPlugin(), // new BundleAnalyzerPlugin(),
) )
return plugins return plugins
......
...@@ -2,6 +2,10 @@ const path = require('path') ...@@ -2,6 +2,10 @@ const path = require('path')
const fs = require('fs-extra') const fs = require('fs-extra')
const config = require('config') const config = require('config')
const { pick } = require('lodash') const { pick } = require('lodash')
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin')
const smp = new SpeedMeasurePlugin()
const rules = require('./common-rules') const rules = require('./common-rules')
const contentBase = path.resolve(__dirname, '..', '_build', 'assets') const contentBase = path.resolve(__dirname, '..', '_build', 'assets')
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment