yarn add webpack webpack-merge
Can be changed, but affects context and resolve.modules in webpack.common.js:
├── config
│ ├── webpack.common.js
│ ├── webpack.dev.js
│ └── webpack.prod.js
└── src
└── …project
| const webpack = require('webpack'); | |
| const path = require('path'); | |
| module.exports = { | |
| context: path.resolve(__dirname, '..', 'src'), | |
| entry: { | |
| app: './app', | |
| }, | |
| module: { | |
| rules: [ | |
| { | |
| test: /\.jsx?$/i, | |
| use: 'babel-loader', | |
| exclude: /node_modules/, | |
| }, | |
| ], | |
| }, | |
| plugins: [ | |
| new webpack.optimize.CommonsChunkPlugin({ | |
| name: 'runtime', | |
| }), | |
| ], | |
| resolve: { | |
| extensions: ['.js', '.jsx'], | |
| modules: ['node_modules', path.resolve(__dirname, '..', 'src')], | |
| }, | |
| }; |
| const webpack = require('webpack'); | |
| const merge = require('webpack-merge'); | |
| const common = require('./webpack.common.js'); | |
| module.exports = merge.smart(common, { | |
| plugins: [ | |
| new webpack.DefinePlugin({ | |
| 'process.env': { | |
| 'NODE_ENV': JSON.stringify('development'), | |
| }, | |
| }), | |
| ], | |
| }); |
| const webpack = require('webpack'); | |
| const merge = require('webpack-merge'); | |
| const common = require('./webpack.common.js'); | |
| module.exports = merge.smart(common, { | |
| plugins: [ | |
| new webpack.DefinePlugin({ | |
| 'process.env': { | |
| 'NODE_ENV': JSON.stringify('production'), | |
| }, | |
| }), | |
| ], | |
| }); |