From 74f6f6519ebde0691955432b1f3463659624fad7 Mon Sep 17 00:00:00 2001 From: Eli Perelman Date: Fri, 3 Mar 2017 15:46:30 -0600 Subject: [PATCH] Fixing json extension --- packages/neutrino-preset-node/index.js | 12 ++--- packages/neutrino-preset-web/index.js | 57 +++++++++++------------ packages/neutrino-preset-web/package.json | 1 + packages/neutrino-preset-web/yarn.lock | 4 ++ 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/packages/neutrino-preset-node/index.js b/packages/neutrino-preset-node/index.js index 5ce1be5..546248a 100644 --- a/packages/neutrino-preset-node/index.js +++ b/packages/neutrino-preset-node/index.js @@ -62,7 +62,7 @@ module.exports = neutrino => { .end() .extensions .add('.js') - .add('json') + .add('.json') .end() .end() .resolveLoader @@ -85,13 +85,9 @@ module.exports = neutrino => { options: { ignore: ['*.js*'] } }); } else { - config - .devtool('inline-sourcemap') - .entry('index') - .add('webpack/hot/poll?1000') - .end() - .output.options.set('devtoolModuleFilenameTemplate', '[absolute-resource-path]'); - + config.devtool('inline-sourcemap'); + config.entry('index').add('webpack/hot/poll?1000'); + config.output.options.set('devtoolModuleFilenameTemplate', '[absolute-resource-path]'); neutrino.use(hot); neutrino.use(startServer, join(SRC, 'index.js')); } diff --git a/packages/neutrino-preset-web/index.js b/packages/neutrino-preset-web/index.js index 9e62e86..6e21baf 100644 --- a/packages/neutrino-preset-web/index.js +++ b/packages/neutrino-preset-web/index.js @@ -14,6 +14,7 @@ const minify = require('neutrino-middleware-minify'); const loaderMerge = require('neutrino-middleware-loader-merge'); const namedModules = require('neutrino-middleware-named-modules'); const { join } = require('path'); +const { pathOr } = require('ramda'); const CWD = process.cwd(); const SRC = join(CWD, 'src'); @@ -23,28 +24,6 @@ const PKG = require(join(CWD, 'package.json')); const PROJECT_MODULES = join(CWD, 'node_modules'); const MODULES = join(__dirname, 'node_modules'); -const devServer = ({ config }, options) => config.devServer - .host(options.host) - .port(parseInt(options.port)) - .https(options.https) - .contentBase(options.contentBase) - .historyApiFallback(true) - .hot(true) - .stats({ - assets: false, - children: false, - chunks: false, - colors: true, - errors: true, - errorDetails: true, - hash: false, - modules: false, - publicPath: false, - timings: false, - version: false, - warnings: true - }); - module.exports = neutrino => { const { config } = neutrino; @@ -95,7 +74,7 @@ module.exports = neutrino => { .chunkFilename('[id].[chunkhash].js'); config.resolve.modules.add(PROJECT_MODULES).add(MODULES); - config.resolve.extensions.add('.js').add('json'); + config.resolve.extensions.add('.js').add('.json'); config.resolveLoader.modules.add(PROJECT_MODULES).add(MODULES); config.node @@ -118,12 +97,8 @@ module.exports = neutrino => { if (process.env.NODE_ENV === 'development') { const protocol = !!process.env.HTTPS ? 'https' : 'http'; - const host = process.env.HOST || - (PKG.neutrino && PKG.neutrino.config && PKG.neutrino.config.devServer && PKG.neutrino.config.devServer.host) || - 'localhost'; - const port = process.env.PORT || - (PKG.neutrino && PKG.neutrino.config && PKG.neutrino.config.devServer && PKG.neutrino.config.devServer.port) || - 5000; + const host = process.env.HOST || pathOr('localhost', ['neutrino', 'config', 'devServer', 'host'], PKG); + const port = process.env.PORT || pathOr(5000, ['neutrino', 'config', 'devServer', 'post'], PKG); neutrino.use(hot); neutrino.use(devServer, { @@ -149,3 +124,27 @@ module.exports = neutrino => { config.output.filename('[name].[chunkhash].bundle.js'); } }; + +function devServer({ config }, options) { + config.devServer + .host(options.host) + .port(parseInt(options.port)) + .https(options.https) + .contentBase(options.contentBase) + .historyApiFallback(true) + .hot(true) + .stats({ + assets: false, + children: false, + chunks: false, + colors: true, + errors: true, + errorDetails: true, + hash: false, + modules: false, + publicPath: false, + timings: false, + version: false, + warnings: true + }); +} diff --git a/packages/neutrino-preset-web/package.json b/packages/neutrino-preset-web/package.json index 34340fe..5a87518 100644 --- a/packages/neutrino-preset-web/package.json +++ b/packages/neutrino-preset-web/package.json @@ -18,6 +18,7 @@ "babel-preset-env": "^1.1.10", "exports-loader": "^0.6.4", "imports-loader": "^0.7.1", + "ramda": "^0.23.0", "webpack": "^2.2.1", "worker-loader": "^0.8.0", "neutrino-middleware-chunk": "^5.0.0", diff --git a/packages/neutrino-preset-web/yarn.lock b/packages/neutrino-preset-web/yarn.lock index 3f976b0..161caf1 100644 --- a/packages/neutrino-preset-web/yarn.lock +++ b/packages/neutrino-preset-web/yarn.lock @@ -1765,6 +1765,10 @@ querystring@0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" +ramda@^0.23.0: + version "0.23.0" + resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.23.0.tgz#ccd13fff73497a93974e3e86327bfd87bd6e8e2b" + randomatic@^1.1.3: version "1.1.6" resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb"