Browse Source

Fixing json extension

v5.0.0-beta
Eli Perelman 8 years ago
parent
commit
74f6f6519e
  1. 12
      packages/neutrino-preset-node/index.js
  2. 57
      packages/neutrino-preset-web/index.js
  3. 1
      packages/neutrino-preset-web/package.json
  4. 4
      packages/neutrino-preset-web/yarn.lock

12
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'));
}

57
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
});
}

1
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",

4
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"

Loading…
Cancel
Save