|
|
@ -3,9 +3,9 @@ const compile = require('neutrino-middleware-compile-loader'); |
|
|
|
const copy = require('neutrino-middleware-copy'); |
|
|
|
const progress = require('neutrino-middleware-progress'); |
|
|
|
const clean = require('neutrino-middleware-clean'); |
|
|
|
const loaderMerge = require('neutrino-middleware-loader-merge'); |
|
|
|
const nodeExternals = require('webpack-node-externals'); |
|
|
|
const { join } = require('path'); |
|
|
|
const merge = require('deepmerge'); |
|
|
|
|
|
|
|
const CWD = process.cwd(); |
|
|
|
const SRC = join(CWD, 'src'); |
|
|
@ -15,8 +15,10 @@ const PROJECT_MODULES = join(CWD, 'node_modules'); |
|
|
|
const MODULES = join(__dirname, 'node_modules'); |
|
|
|
const PKG = require(join(CWD, 'package.json')); |
|
|
|
|
|
|
|
module.exports = (config, neutrino) => { |
|
|
|
neutrino.use(compile({ |
|
|
|
module.exports = neutrino => { |
|
|
|
const { config } = neutrino; |
|
|
|
|
|
|
|
neutrino.use(compile, { |
|
|
|
include: [SRC, TEST], |
|
|
|
babel: { |
|
|
|
presets: [ |
|
|
@ -28,7 +30,7 @@ module.exports = (config, neutrino) => { |
|
|
|
}] |
|
|
|
] |
|
|
|
} |
|
|
|
})); |
|
|
|
}); |
|
|
|
|
|
|
|
config.options.set('performance', { hints: false }); |
|
|
|
config |
|
|
@ -68,60 +70,57 @@ module.exports = (config, neutrino) => { |
|
|
|
(PKG.devDependencies && 'source-map-support' in PKG.devDependencies); |
|
|
|
|
|
|
|
if (hasSourceMap) { |
|
|
|
neutrino.use(banner()); |
|
|
|
neutrino.use(banner); |
|
|
|
} |
|
|
|
|
|
|
|
if (process.env.NODE_ENV !== 'development') { |
|
|
|
neutrino.use([ |
|
|
|
copy({ patterns: [{ context: SRC, from: `**/*` }], options: { ignore: ['*.js*'] } }), |
|
|
|
progress(), |
|
|
|
clean({ paths: [BUILD] }) |
|
|
|
]) |
|
|
|
neutrino.use(clean, { paths: [BUILD] }); |
|
|
|
neutrino.use(progress); |
|
|
|
neutrino.use(copy, { |
|
|
|
patterns: [{ context: SRC, from: `**/*` }], |
|
|
|
options: { ignore: ['*.js*'] } |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
if (config.module.rules.has('lint')) { |
|
|
|
config.module |
|
|
|
.rule('lint') |
|
|
|
.loader('eslint', props => merge(props, { |
|
|
|
options: { |
|
|
|
envs: ['node'], |
|
|
|
rules: { |
|
|
|
// enforce return after a callback
|
|
|
|
'callback-return': 'off', |
|
|
|
neutrino.use(loaderMerge('lint', 'eslint'), { |
|
|
|
envs: ['node'], |
|
|
|
rules: { |
|
|
|
// enforce return after a callback
|
|
|
|
'callback-return': 'off', |
|
|
|
|
|
|
|
// require all requires be top-level
|
|
|
|
// http://eslint.org/docs/rules/global-require
|
|
|
|
'global-require': 'error', |
|
|
|
// require all requires be top-level
|
|
|
|
// http://eslint.org/docs/rules/global-require
|
|
|
|
'global-require': 'error', |
|
|
|
|
|
|
|
// enforces error handling in callbacks (node environment)
|
|
|
|
'handle-callback-err': 'off', |
|
|
|
// enforces error handling in callbacks (node environment)
|
|
|
|
'handle-callback-err': 'off', |
|
|
|
|
|
|
|
// Allow console in Node.js
|
|
|
|
'no-console': 'off', |
|
|
|
// Allow console in Node.js
|
|
|
|
'no-console': 'off', |
|
|
|
|
|
|
|
// disallow mixing regular variable and require declarations
|
|
|
|
'no-mixed-requires': ['off', false], |
|
|
|
// disallow mixing regular variable and require declarations
|
|
|
|
'no-mixed-requires': ['off', false], |
|
|
|
|
|
|
|
// disallow use of new operator with the require function
|
|
|
|
'no-new-require': 'error', |
|
|
|
// disallow use of new operator with the require function
|
|
|
|
'no-new-require': 'error', |
|
|
|
|
|
|
|
// disallow string concatenation with __dirname and __filename
|
|
|
|
// http://eslint.org/docs/rules/no-path-concat
|
|
|
|
'no-path-concat': 'error', |
|
|
|
// disallow string concatenation with __dirname and __filename
|
|
|
|
// http://eslint.org/docs/rules/no-path-concat
|
|
|
|
'no-path-concat': 'error', |
|
|
|
|
|
|
|
// disallow use of process.env
|
|
|
|
'no-process-env': 'off', |
|
|
|
// disallow use of process.env
|
|
|
|
'no-process-env': 'off', |
|
|
|
|
|
|
|
// disallow process.exit()
|
|
|
|
'no-process-exit': 'off', |
|
|
|
// disallow process.exit()
|
|
|
|
'no-process-exit': 'off', |
|
|
|
|
|
|
|
// restrict usage of specified node modules
|
|
|
|
'no-restricted-modules': 'off', |
|
|
|
// restrict usage of specified node modules
|
|
|
|
'no-restricted-modules': 'off', |
|
|
|
|
|
|
|
// disallow use of synchronous methods (off by default)
|
|
|
|
'no-sync': 'off' |
|
|
|
} |
|
|
|
} |
|
|
|
})); |
|
|
|
// disallow use of synchronous methods (off by default)
|
|
|
|
'no-sync': 'off' |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}; |
|
|
|