You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.2 KiB
84 lines
2.2 KiB
8 years ago
|
const web = require('neutrino-preset-web');
|
||
8 years ago
|
const merge = require('deepmerge');
|
||
8 years ago
|
const { join } = require('path');
|
||
|
|
||
|
const MODULES = join(__dirname, 'node_modules');
|
||
|
|
||
|
module.exports = (config, neutrino) => {
|
||
|
neutrino.use(web);
|
||
|
|
||
|
config.resolve.modules.add(MODULES);
|
||
|
config.resolve.extensions.add('.jsx');
|
||
|
config.resolveLoader.modules.add(MODULES);
|
||
8 years ago
|
|
||
8 years ago
|
config
|
||
|
.externals({
|
||
|
'react/addons': true,
|
||
|
'react/lib/ExecutionEnvironment': true,
|
||
|
'react/lib/ReactContext': 'window'
|
||
|
});
|
||
8 years ago
|
|
||
8 years ago
|
config.module
|
||
|
.rule('compile')
|
||
|
.test(/\.jsx?$/)
|
||
|
.loader('babel', props => merge(props, {
|
||
|
options: {
|
||
|
presets: [require.resolve('babel-preset-react')],
|
||
|
plugins: [require.resolve('babel-plugin-transform-object-rest-spread')],
|
||
|
env: {
|
||
|
development: {
|
||
|
plugins: [require.resolve('react-hot-loader/babel')]
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}));
|
||
8 years ago
|
|
||
8 years ago
|
if (process.env.NODE_ENV === 'development') {
|
||
|
config
|
||
|
.entry('index')
|
||
|
.prepend(require.resolve('react-hot-loader/patch'));
|
||
|
}
|
||
8 years ago
|
|
||
8 years ago
|
if (config.module.rules.has('lint')) {
|
||
|
config.module
|
||
|
.rule('lint')
|
||
|
.test(/\.jsx?$/)
|
||
8 years ago
|
.loader('eslint', props => merge(props, {
|
||
|
options: {
|
||
|
plugins: ['react'],
|
||
|
baseConfig: {
|
||
|
extends: ['plugin:react/recommended']
|
||
|
},
|
||
|
parserOptions: {
|
||
|
ecmaFeatures: {
|
||
|
experimentalObjectRestSpread: true
|
||
8 years ago
|
}
|
||
8 years ago
|
},
|
||
|
rules: {
|
||
|
'react/prop-types': ['off'],
|
||
|
'jsx-quotes': ['error', 'prefer-double'],
|
||
|
'class-methods-use-this': ['error', {
|
||
|
exceptMethods: [
|
||
|
'render',
|
||
|
'getInitialState',
|
||
|
'getDefaultProps',
|
||
|
'getChildContext',
|
||
|
'componentWillMount',
|
||
|
'componentDidMount',
|
||
|
'componentWillReceiveProps',
|
||
|
'shouldComponentUpdate',
|
||
|
'componentWillUpdate',
|
||
|
'componentDidUpdate',
|
||
|
'componentWillUnmount'
|
||
|
]
|
||
|
}]
|
||
|
}
|
||
|
}
|
||
|
}));
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
8 years ago
|
// console.log(config.module.toConfig());
|
||
|
// console.log(neutrino.getWebpackOptions().module.rules);
|
||
|
// process.exit();
|
||
8 years ago
|
};
|