From d9d3e5a84b4e925382e7d464a1b36905ce0d8a9f Mon Sep 17 00:00:00 2001 From: cha0s Date: Mon, 22 Mar 2021 02:53:25 -0500 Subject: [PATCH] refactor: build --- app/.neutrinorc.js | 91 +------------------------- app/package.json | 17 ++--- app/webpack.config.js | 43 +++++++----- app/yarn.lock | 108 +------------------------------ config/.eslint.defaults.js | 22 ------- config/.eslintrc.js | 3 - config/.mocharc.js | 5 -- config/.neutrinorc.js | 108 ------------------------------- config/package/.eslintrc.js | 1 - config/package/.neutrinorc.js | 1 - config/package/postcss.config.js | 6 -- config/package/webpack.config.js | 3 - 12 files changed, 38 insertions(+), 370 deletions(-) delete mode 100644 config/.eslint.defaults.js delete mode 100644 config/.eslintrc.js delete mode 100644 config/.mocharc.js delete mode 100644 config/.neutrinorc.js delete mode 100644 config/package/.eslintrc.js delete mode 100644 config/package/.neutrinorc.js delete mode 100644 config/package/postcss.config.js delete mode 100644 config/package/webpack.config.js diff --git a/app/.neutrinorc.js b/app/.neutrinorc.js index 5eb9047..439b3d2 100644 --- a/app/.neutrinorc.js +++ b/app/.neutrinorc.js @@ -1,17 +1,6 @@ require('dotenv/config'); -const airbnb = require('@neutrinojs/airbnb'); -const clean = require('@neutrinojs/clean'); -const copy = require('@neutrinojs/copy'); -const mocha = require('@neutrinojs/mocha'); -const node = require('@neutrinojs/node'); -const {EnvironmentPlugin} = require('webpack'); -const nodeExternals = require('webpack-node-externals'); - -const { - LATUS_ESLINT_DEFAULTS = require.resolve('@latus/build/build/.eslint.defaults.js'), - LATUS_WEBPACK_CONFIG = require.resolve('@latus/build/build/webpack.config.js'), -} = process.env; +const {server} = require('@latus/build'); module.exports = { options: { @@ -19,84 +8,10 @@ module.exports = { }, use: [ (neutrino) => { - neutrino.options.mains.electron = {entry: './src/electron'}; + const entry = neutrino.config.entry('electron').clear(); + entry.add('./src/electron'); }, - airbnb({ - eslint: { - cache: false, - baseConfig: require(LATUS_ESLINT_DEFAULTS), - }, - }), - clean({ - cleanOnceBeforeBuildPatterns: ['**/*.hot-update.*'], - }), - copy({ - patterns: [{ - from: 'src/assets', - to: 'http', - }], - }), - mocha(), - node({ - hot: true, - }), (neutrino) => { - [ - 'components', - 'context', - 'fonts', - 'hooks', - 'images', - 'scss', - ].forEach((path) => { - neutrino.config.resolve.alias - .set(path, `${neutrino.options.source}/react/${path}`); - }); - if (process.env.LATUS_LINTING) { - return; - } - neutrino.config.module - .rule('compile') - .use('babel') - .get('options').plugins.push( - [ - 'babel-plugin-webpack-alias', - { - config: LATUS_WEBPACK_CONFIG, - }, - ], - ); - neutrino.config - .plugin('environment') - .use(EnvironmentPlugin, [{ - SIDE: 'server', - }]); - neutrino.config - .entry('index') - .add('@latus/core/start'); - if ('production' !== neutrino.config.get('mode')) { - neutrino.config - .entry('index') - .prepend('dotenv/config'); - neutrino.config - .plugin('start-server') - .tap((args) => { - const options = args[0]; - options.signal = true; - const inspectArg = process.argv.find((arg) => -1 !== arg.indexOf('--inspect')); - if (inspectArg) { - options.nodeArgs.push(inspectArg); - } - const profArg = process.argv.find((arg) => -1 !== arg.indexOf('--prof')); - if (profArg) { - options.nodeArgs.push(profArg); - } - options.nodeArgs.push('--experimental-repl-await'); - options.nodeArgs.push('--unhandled-rejections=strict'); - return args; - }); - } - neutrino.config.externals(nodeExternals()); neutrino.config.resolve.alias .set('pixi.js', 'pixi.js-legacy') .set('react-dom', '@hot-loader/react-dom'); diff --git a/app/package.json b/app/package.json index f89b148..2571155 100644 --- a/app/package.json +++ b/app/package.json @@ -5,14 +5,15 @@ "scripts": { "build": "latus-build", "clean": "latus-build clean", - "dev": "webpack --mode development", + "client": "LATUS_EXCLUDE_BUILD=server latus-build -d --hot --watch", + "dev": "latus-build -d --hot --watch --start-server --inspect", "docker": "yarn run build && docker build", "electron": "NODE_ENV=production NODE_PATH=./node_modules electron build/electron.js", "lint": "latus-build lint", "repl": "rlwrap -C qmp socat STDIO UNIX:$(ls /tmp/latus-*.sock | tail -n 1)", + "server": "LATUS_EXCLUDE_BUILD=http latus-build -d --hot --start-server --inspect", "start": "NODE_ENV=production NODE_PATH=./node_modules node build/index.js", - "test": "latus-build test", - "watch": "latus-build -d --hot --watch" + "test": "latus-build test" }, "dependencies": { "@avocado/behavior": "^2.0.0", @@ -45,7 +46,6 @@ "@latus/repl": "2.0.0", "@latus/socket": "2.0.0", "@latus/user": "2.0.0", - "autoprefixer": "^9.8.6", "classnames": "^2.2.6", "connected-react-router": "^6.8.0", "dotenv": "8.2.0", @@ -53,19 +53,12 @@ "history": "^4.7.2", "is-electron": "^2.2.0", "pixi.js-legacy": "^5.3.7", - "prop-types": "^15.7.2", - "react": "^17.0.1", - "react-hot-loader": "4.13.0", "react-router": "^5.2.0", "react-router-dom": "^5.2.0", - "screenfull": "^5.1.0", - "source-map-loader": "^1.1.3" + "screenfull": "^5.1.0" }, "devDependencies": { "@latus/build": "1.x", - "@neutrinojs/copy": "^9.4.0", - "@neutrinojs/node": "^9.1.0", - "babel-plugin-webpack-alias": "^2.1.2", "source-map-support": "0.5.19" } } diff --git a/app/webpack.config.js b/app/webpack.config.js index 65d8027..4364a86 100644 --- a/app/webpack.config.js +++ b/app/webpack.config.js @@ -1,28 +1,39 @@ require('source-map-support/register'); -// Whilst the configuration object can be modified here, the recommended way of making -// changes is via the presets' options or Neutrino's API in `.neutrinorc.js` instead. -// Neutrino's inspect feature can be used to view/export the generated configuration. + const {Latus} = require('@latus/core'); const neutrino = require('neutrino'); -if (process.env.LATUS_LINTING) { - // eslint-disable-next-line global-require - module.exports = neutrino(require('./.neutrinorc')).webpack(); -} -else { - module.exports = new Promise((resolve, reject) => { +const server = require('./.neutrinorc'); + +const { + LATUS_EXCLUDE_BUILD = '' +} = process.env; + +const excludeBuilds = LATUS_EXCLUDE_BUILD.split(',').map((name) => name.trim()); + +module.exports = process.env.LATUS_LINTING + ? neutrino(server).webpack() + : new Promise((resolve, reject) => { try { const latus = Latus.create(); - const configs = { - // eslint-disable-next-line global-require - app: require('./.neutrinorc'), - }; + const configs = {server}; latus.invokeFlat('@latus/core/build', configs); - const webpackConfigs = Object.values(configs).map((config) => neutrino(config).webpack()); - resolve(webpackConfigs); + const webpackConfigs = Object.values( + Object.entries(configs) + .reduce( + (r, [name, config]) => ({ + ...r, + ...(-1 !== excludeBuilds.indexOf(name) ? {} : {[name]: config}), + }), + {}, + ) + ) + .map((config) => neutrino(config).webpack()); + if (webpackConfigs.length > 0) { + resolve(webpackConfigs); + } } catch (error) { reject(error); } }); -} diff --git a/app/yarn.lock b/app/yarn.lock index 6a9cced..ad7d143 100644 --- a/app/yarn.lock +++ b/app/yarn.lock @@ -1406,7 +1406,7 @@ eslint-plugin-react "^7.21.5" eslint-plugin-react-hooks "^4.2.0" -"@neutrinojs/banner@9.5.0", "@neutrinojs/banner@^9.4.0": +"@neutrinojs/banner@^9.4.0": version "9.5.0" resolved "http://npm.cha0sdev/@neutrinojs%2fbanner/-/banner-9.5.0.tgz#ee8df39db5d76033211a1811428e444a06d7222f" integrity sha512-SL4nT0V1Wykf+LcRlCp/L8Frt4dk7MZITToC+OeDz2w6V7gg8YfEwDfdEg+aampjyUoxaq+A02ZyZP1TyRDtLA== @@ -1488,23 +1488,6 @@ deepmerge "^1.5.2" lodash.omit "^4.5.0" -"@neutrinojs/node@^9.1.0": - version "9.5.0" - resolved "http://npm.cha0sdev/@neutrinojs%2fnode/-/node-9.5.0.tgz#41da54a6af461ca329b194063640a2aa0e84f32e" - integrity sha512-kJjdEKCdBnKWD51Qnm6REAUdaLrJc3qjA3wFcJ11v1wddu7Ihaa2S4qNjcrCDYrxSPD1vVoUlE+nyucsX+dO4w== - dependencies: - "@babel/core" "^7.12.10" - "@babel/plugin-syntax-dynamic-import" "^7.8.3" - "@babel/preset-env" "^7.12.11" - "@neutrinojs/banner" "9.5.0" - "@neutrinojs/clean" "9.5.0" - "@neutrinojs/compile-loader" "9.5.0" - "@neutrinojs/start-server" "9.5.0" - babel-merge "^3.0.0" - deepmerge "^1.5.2" - lodash.omit "^4.5.0" - webpack-node-externals "^1.7.2" - "@neutrinojs/react@^9.4.0": version "9.5.0" resolved "http://npm.cha0sdev/@neutrinojs%2freact/-/react-9.5.0.tgz#3ea0c94aaef7045c74fc53b581d7e989a83e67dd" @@ -1519,13 +1502,6 @@ eslint-plugin-react "^7.21.5" eslint-plugin-react-hooks "^4.2.0" -"@neutrinojs/start-server@9.5.0": - version "9.5.0" - resolved "http://npm.cha0sdev/@neutrinojs%2fstart-server/-/start-server-9.5.0.tgz#f0d21a7f2c9c57897769e56ee042bd1d242275a4" - integrity sha512-gNRISZAbJpAZRIUfIxCWFEzEhfM/4ibmbGzz9jFJloH+fQw6JpOWF6bhhBZNDFFTj/6GKFi40CJrte4V3ywNBA== - dependencies: - start-server-webpack-plugin "^2.2.5" - "@neutrinojs/style-loader@9.5.0": version "9.5.0" resolved "http://npm.cha0sdev/@neutrinojs%2fstyle-loader/-/style-loader-9.5.0.tgz#5f1f151d76f5f1168e557612d5e3407ffb99049e" @@ -2731,34 +2707,6 @@ babel-plugin-transform-react-remove-prop-types@^0.4.24: resolved "http://npm.cha0sdev/babel-plugin-transform-react-remove-prop-types/-/babel-plugin-transform-react-remove-prop-types-0.4.24.tgz#f2edaf9b4c6a5fbe5c1d678bfb531078c1555f3a" integrity sha512-eqj0hVcJUR57/Ug2zE1Yswsw4LhuqqHhD+8v120T1cl3kjg76QwtyBrdIk4WVwK+lAhBJVYCd/v+4nc4y+8JsA== -babel-plugin-webpack-alias@^2.1.2: - version "2.1.2" - resolved "http://npm.cha0sdev/babel-plugin-webpack-alias/-/babel-plugin-webpack-alias-2.1.2.tgz#05a1ba23c28595660fb6ea5736424fc596b4a247" - integrity sha1-BaG6I8KFlWYPtupXNkJPxZa0okc= - dependencies: - babel-types "^6.14.0" - find-up "^2.0.0" - lodash.some "^4.5.1" - lodash.template "^4.3.0" - -babel-runtime@^6.26.0: - version "6.26.0" - resolved "http://npm.cha0sdev/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" - integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= - dependencies: - core-js "^2.4.0" - regenerator-runtime "^0.11.0" - -babel-types@^6.14.0: - version "6.26.0" - resolved "http://npm.cha0sdev/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" - integrity sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc= - dependencies: - babel-runtime "^6.26.0" - esutils "^2.0.2" - lodash "^4.17.4" - to-fast-properties "^1.0.3" - backo2@~1.0.2: version "1.0.2" resolved "http://npm.cha0sdev/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947" @@ -3640,11 +3588,6 @@ core-js-pure@^3.0.0: resolved "http://npm.cha0sdev/core-js-pure/-/core-js-pure-3.8.3.tgz#10e9e3b2592ecaede4283e8f3ad7020811587c02" integrity sha512-V5qQZVAr9K0xu7jXg1M7qTEwuxUgqr7dUOezGaNa7i+Xn9oXAU/d1fzqD9ObuwpVQOaorO5s70ckyi1woP9lVA== -core-js@^2.4.0: - version "2.6.12" - resolved "http://npm.cha0sdev/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" - integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== - core-js@^3.6.5: version "3.8.3" resolved "http://npm.cha0sdev/core-js/-/core-js-3.8.3.tgz#c21906e1f14f3689f93abcc6e26883550dd92dd0" @@ -6577,11 +6520,6 @@ locate-path@^6.0.0: dependencies: p-locate "^5.0.0" -lodash._reinterpolate@^3.0.0: - version "3.0.0" - resolved "http://npm.cha0sdev/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" - integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0= - lodash.clonedeep@^4.5.0: version "4.5.0" resolved "http://npm.cha0sdev/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" @@ -6612,26 +6550,6 @@ lodash.set@^4.3.2: resolved "http://npm.cha0sdev/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23" integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM= -lodash.some@^4.5.1: - version "4.6.0" - resolved "http://npm.cha0sdev/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d" - integrity sha1-G7nzFO9ri63tE7VJFpsqlF62jk0= - -lodash.template@^4.3.0: - version "4.5.0" - resolved "http://npm.cha0sdev/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab" - integrity sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A== - dependencies: - lodash._reinterpolate "^3.0.0" - lodash.templatesettings "^4.0.0" - -lodash.templatesettings@^4.0.0: - version "4.2.0" - resolved "http://npm.cha0sdev/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz#e481310f049d3cf6d47e912ad09313b154f0fb33" - integrity sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ== - dependencies: - lodash._reinterpolate "^3.0.0" - lodash.throttle@^4.1.1: version "4.1.1" resolved "http://npm.cha0sdev/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" @@ -6647,7 +6565,7 @@ lodash.without@^4.4.0: resolved "http://npm.cha0sdev/lodash.without/-/lodash.without-4.4.0.tgz#3cd4574a00b67bae373a94b748772640507b7aac" integrity sha1-PNRXSgC2e643OpS3SHcmQFB7eqw= -lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.4, lodash@~4.17.10: +lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@~4.17.10: version "4.17.20" resolved "http://npm.cha0sdev/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== @@ -8496,7 +8414,7 @@ react-hex-editor@^0.3.0: react-virtualized-auto-sizer "^1.0.2" react-window "^1.8.5" -react-hot-loader@4.13.0, react-hot-loader@^4.13.0: +react-hot-loader@^4.13.0: version "4.13.0" resolved "http://npm.cha0sdev/react-hot-loader/-/react-hot-loader-4.13.0.tgz#c27e9408581c2a678f5316e69c061b226dc6a202" integrity sha512-JrLlvUPqh6wIkrK2hZDfOyq/Uh/WeVEr8nc7hkn2/3Ul0sx1Kr5y4kOGNacNRoj7RhwLNcQ3Udf1KJXrqc0ZtA== @@ -8779,11 +8697,6 @@ regenerate@^1.4.0: resolved "http://npm.cha0sdev/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== -regenerator-runtime@^0.11.0: - version "0.11.1" - resolved "http://npm.cha0sdev/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" - integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== - regenerator-runtime@^0.13.4: version "0.13.7" resolved "http://npm.cha0sdev/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55" @@ -9669,11 +9582,6 @@ ssri@^6.0.1: dependencies: figgy-pudding "^3.5.1" -start-server-webpack-plugin@^2.2.5: - version "2.2.5" - resolved "http://npm.cha0sdev/start-server-webpack-plugin/-/start-server-webpack-plugin-2.2.5.tgz#4a2838759b0f36acd11b0b2f5f196f289ae29d31" - integrity sha512-DRCkciwCJoCFZ+wt3wWMkR1M2mpVhJbUKFXqhK3FWyIUKYb42NnocH5sMwqgo+nPNHupqNwK/v8lgfBbr2NKdg== - static-extend@^0.1.1: version "0.1.2" resolved "http://npm.cha0sdev/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" @@ -10050,11 +9958,6 @@ to-arraybuffer@^1.0.0: resolved "http://npm.cha0sdev/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" integrity sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M= -to-fast-properties@^1.0.3: - version "1.0.3" - resolved "http://npm.cha0sdev/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" - integrity sha1-uDVx+k2MJbguIxsG46MFXeTKGkc= - to-fast-properties@^2.0.0: version "2.0.0" resolved "http://npm.cha0sdev/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" @@ -10579,11 +10482,6 @@ webpack-log@^2.0.0: ansi-colors "^3.0.0" uuid "^3.3.2" -webpack-node-externals@^1.7.2: - version "1.7.2" - resolved "http://npm.cha0sdev/webpack-node-externals/-/webpack-node-externals-1.7.2.tgz#6e1ee79ac67c070402ba700ef033a9b8d52ac4e3" - integrity sha512-ajerHZ+BJKeCLviLUUmnyd5B4RavLF76uv3cs6KNuO8W+HuQaEs0y0L7o40NQxdPy5w0pcv8Ew7yPUAQG0UdCg== - webpack-sources@^1.1.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1: version "1.4.3" resolved "http://npm.cha0sdev/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933" diff --git a/config/.eslint.defaults.js b/config/.eslint.defaults.js deleted file mode 100644 index 624bae6..0000000 --- a/config/.eslint.defaults.js +++ /dev/null @@ -1,22 +0,0 @@ -const config = { - globals: { - process: true, - window: true, - }, - ignorePatterns: [ - '/*', - '!/src', - ], - rules: { - 'babel/object-curly-spacing': 'off', - 'brace-style': ['error', 'stroustrup'], - 'no-bitwise': ['error', {int32Hint: true}], - 'no-plusplus': 'off', - 'no-shadow': 'off', - 'no-underscore-dangle': 'off', - 'padded-blocks': ['error', {classes: 'always'}], - yoda: 'off', - }, -}; - -module.exports = config; diff --git a/config/.eslintrc.js b/config/.eslintrc.js deleted file mode 100644 index d0c2c7f..0000000 --- a/config/.eslintrc.js +++ /dev/null @@ -1,3 +0,0 @@ -const neutrino = require('neutrino'); - -module.exports = neutrino(require(`${__dirname}/.neutrinorc`)).eslintrc(); diff --git a/config/.mocharc.js b/config/.mocharc.js deleted file mode 100644 index 3cd88d6..0000000 --- a/config/.mocharc.js +++ /dev/null @@ -1,5 +0,0 @@ -const neutrino = require('neutrino'); - -process.env.NODE_ENV = process.env.NODE_ENV || 'test'; - -module.exports = neutrino(require(`${__dirname}/.neutrinorc`)).mocha(); diff --git a/config/.neutrinorc.js b/config/.neutrinorc.js deleted file mode 100644 index 1760bba..0000000 --- a/config/.neutrinorc.js +++ /dev/null @@ -1,108 +0,0 @@ -const {basename, dirname, extname, join} = require('path'); - -const airbnb = require('@neutrinojs/airbnb'); -const glob = require('glob'); -const mocha = require('@neutrinojs/mocha'); -const react = require('@neutrinojs/react'); -const nodeExternals = require('webpack-node-externals'); - -module.exports = { - options: {}, - use: [ - airbnb({ - eslint: { - cache: false, - baseConfig: require(`${__dirname}/.eslint.defaults`), - }, - }), - (neutrino) => { - const {files = [], name} = neutrino.options.packageJson; - files - .filter((file) => { - const {source} = neutrino.options; - try { - require.resolve(`${source}/${file}`); - return true; - } - catch (error) { - const ext = extname(file); - try { - require.resolve(`${source}/${dirname(file)}/${basename(file, ext)}/index${ext}`); - return true; - } - catch (error) { - return false; - } - } - }) - .forEach((file) => { - const isIndex = 'index.js' === file; - const trimmed = join(dirname(file), basename(file, extname(file))); - neutrino.options.mains[trimmed] = {entry: isIndex ? file : `./src/${trimmed}`}; - }); - const testPaths = glob.sync('./test/*.js'); - if (testPaths.length > 0) { - const testEntry = neutrino.config.entry('test').clear(); - testPaths.forEach((path) => testEntry.add(path)); - } - const cssPaths = glob.sync('./src/**/*.{css,scss}'); - if (cssPaths.length > 0) { - const cssEntry = neutrino.config.entry('index.css').clear(); - cssPaths.forEach((path) => cssEntry.add(path)); - } - neutrino.options.output = '.'; - react({ - clean: false, - hot: false, - style: { - extract: { - enabled: false, - }, - test: /\.(css|sass|scss)$/, - modulesTest: /\.module\.(css|sass|scss)$/, - loaders: [ - { - loader: 'postcss-loader', - useId: 'postcss', - options: { - config: { - path: process.cwd(), - }, - }, - }, - { - loader: 'sass-loader', - useId: 'sass', - }, - ], - }, - })(neutrino); - Object.keys(neutrino.options.mains).forEach((main) => { - neutrino.config.plugins.delete(`html-${main}`); - }); - neutrino.config - .devtool('source-map') - .target('node') - .optimization - .splitChunks(false) - .runtimeChunk(false) - .end() - .output - .filename('[name].js') - .library(name) - .libraryTarget('umd') - .umdNamedDefine(true) - .end() - .node - .set('__dirname', false) - .set('__filename', false); - const options = neutrino.config.module - .rule('compile') - .use('babel') - .get('options'); - options.presets[0][1].targets = {esmodules: true}; - neutrino.config.externals(nodeExternals({importType: 'umd'})); - }, - mocha(), - ], -}; diff --git a/config/package/.eslintrc.js b/config/package/.eslintrc.js deleted file mode 100644 index 783c96d..0000000 --- a/config/package/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('../../config/.eslintrc'); diff --git a/config/package/.neutrinorc.js b/config/package/.neutrinorc.js deleted file mode 100644 index d6c3d9d..0000000 --- a/config/package/.neutrinorc.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('../../config/.neutrinorc'); diff --git a/config/package/postcss.config.js b/config/package/postcss.config.js deleted file mode 100644 index 08c5240..0000000 --- a/config/package/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable global-require */ -module.exports = { - plugins: [ - require('autoprefixer'), - ], -}; diff --git a/config/package/webpack.config.js b/config/package/webpack.config.js deleted file mode 100644 index 1046c78..0000000 --- a/config/package/webpack.config.js +++ /dev/null @@ -1,3 +0,0 @@ -const neutrino = require('neutrino'); - -module.exports = neutrino(require(`${__dirname}/.neutrinorc`)).webpack();