Commit 8c95163e authored by Mickaël Bourgier's avatar Mickaël Bourgier
Browse files

🔥 Remove unnecessary compilation code

parent b5b3dd8d
Pipeline #1773 passed with stage
in 1 minute and 40 seconds
const test = process.env.NODE_ENV === 'test';
const cjs = process.env.BABEL_ENV === 'cjs';
const es = process.env.BABEL_ENV === 'es';
module.exports = {
presets: [
[
'@babel/preset-env',
{
modules: test || cjs ? 'cjs' : false,
},
],
'@babel/preset-react',
],
presets: [['@babel/preset-env', { modules: false }], '@babel/preset-react'],
plugins: ['@babel/plugin-proposal-class-properties', 'dev-expression'],
ignore: [
...(cjs || es ? [/demos\/.+\.js/] : []),
...(test ? [] : [/\.test\.js/]),
],
};
......@@ -31,8 +31,8 @@
"build:cjs": "tsc --rootDir ./src --outDir ./dist --declaration",
"build:es": "tsc --rootDir ./src --outDir ./dist/es --declaration --target ES6 --moduleResolution node",
"build:check": "tsc --noEmit",
"dev": "WEBPACK_TARGET=docs yarn docs:dev",
"docs:build": "rm -rf docs/dist && NODE_ENV=production WEBPACK_TARGET=docs webpack",
"dev": "yarn docs:dev",
"docs:build": "rm -rf docs/dist && NODE_ENV=production webpack",
"docs:dev": "webpack-dev-server --hot",
"lint": "eslint './docs/**/*.{js,ts,tsx}' './src/**/*.{js,ts,tsx}'",
"prepublishOnly": "yarn prettier:check && yarn lint && yarn build",
......
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const production = process.env.NODE_ENV === 'production';
const docs = process.env.WEBPACK_TARGET === 'docs';
module.exports = {
context: __dirname,
mode: production ? 'production' : 'development',
entry: docs
? {
[`app${production ? '.min' : ''}`]: path.resolve(
__dirname,
'docs/src/index.js'
),
}
: {
'react.webf': path.resolve(__dirname, 'src/index.js'),
...(production
? { 'react.webf.min': path.resolve(__dirname, 'src/index.js') }
: {}),
},
entry: {
[`app${production ? '.min' : ''}`]: path.resolve(
__dirname,
'docs/src/index.js'
),
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, docs ? 'docs/dist' : 'dist'),
path: path.resolve(__dirname, 'docs/dist'),
publicPath: '/',
},
......@@ -59,19 +52,17 @@ module.exports = {
],
},
plugins: docs
? [
new HtmlWebpackPlugin({
alwaysWriteToDisk: true,
hash: true,
meta: {
viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no',
},
template: path.resolve(__dirname, 'docs/static/index.html'),
}),
new HtmlWebpackHarddiskPlugin(),
]
: [],
plugins: [
new HtmlWebpackPlugin({
alwaysWriteToDisk: true,
hash: true,
meta: {
viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no',
},
template: path.resolve(__dirname, 'docs/static/index.html'),
}),
new HtmlWebpackHarddiskPlugin(),
],
resolve: {
alias: {
......
Markdown is supported
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