|
| 1 | +import HTMLwebpackPlugin from 'html-webpack-plugin' |
| 2 | +import autoprefixer from 'autoprefixer' |
| 3 | +import path from 'path' |
| 4 | +import webpack from 'webpack' |
| 5 | +const entries = [ |
| 6 | + 'react-hot-loader/patch', |
| 7 | + 'webpack-hot-middleware/client', |
| 8 | + './app/', |
| 9 | +] |
| 10 | + |
| 11 | + |
| 12 | +export default { |
| 13 | + browser: { |
| 14 | + entry: entries, |
| 15 | + resolve: { |
| 16 | + extensions: ['.webpack.js', '.web.js', '.js', '.jsx', '.scss', '.html', '.ejs'], |
| 17 | + }, |
| 18 | + node: { |
| 19 | + fs: 'empty', |
| 20 | + }, |
| 21 | + module: { |
| 22 | + rules: [ |
| 23 | + { |
| 24 | + test: /\.scss$/, |
| 25 | + loaders: [ |
| 26 | + 'style-loader', |
| 27 | + 'css-loader?modules&importLoaders=1&localIdentName=[path][name]__[local]__[hash:base64:10]', |
| 28 | + 'sass-loader', |
| 29 | + 'sass-resources-loader', |
| 30 | + 'import-glob-loader', |
| 31 | + 'postcss-loader', |
| 32 | + ], |
| 33 | + }, |
| 34 | + { |
| 35 | + test: /\.jpe?g$|\.gif$|\.png$|\.ico$|\.svg$/, |
| 36 | + loader: 'file-loader?name=../img/[name].[ext]', |
| 37 | + }, |
| 38 | + { |
| 39 | + test: /\.(woff|woff2|eot|ttf)$/, |
| 40 | + loader: 'url-loader', |
| 41 | + }, |
| 42 | + { |
| 43 | + test: /\.jsx?$/, |
| 44 | + loader: 'babel-loader', |
| 45 | + exclude: /node_modules/, |
| 46 | + } |
| 47 | + ], |
| 48 | + }, |
| 49 | + output: { |
| 50 | + path: path.resolve('./build/assets/'), |
| 51 | + filename: 'bundle.js', |
| 52 | + publicPath: '/assets/', |
| 53 | + }, |
| 54 | + plugins: [ |
| 55 | + new HTMLwebpackPlugin({ |
| 56 | + filename: '../index.html', |
| 57 | + template: './app/views/index.ejs', |
| 58 | + }), |
| 59 | + new webpack.HotModuleReplacementPlugin(), |
| 60 | + new webpack.NoErrorsPlugin(), |
| 61 | + new webpack.LoaderOptionsPlugin({ |
| 62 | + options: { |
| 63 | + postcss: [ |
| 64 | + autoprefixer(), |
| 65 | + ], |
| 66 | + sassResources: [ |
| 67 | + './app/constants/_style-variables.scss', |
| 68 | + ], |
| 69 | + context: path.resolve(__dirname, '../../') |
| 70 | + } |
| 71 | + }) |
| 72 | + ], |
| 73 | + }, |
| 74 | + server: { |
| 75 | + entry: './server/', |
| 76 | + resolve: { |
| 77 | + extensions: ['.js'], |
| 78 | + }, |
| 79 | + node: { |
| 80 | + __dirname: false, |
| 81 | + __filename: false, |
| 82 | + }, |
| 83 | + externals: /^[a-z\-0-9]+$/, |
| 84 | + module: { |
| 85 | + rules: [ |
| 86 | + { |
| 87 | + test: /\.js$/, |
| 88 | + loader: 'babel-loader', |
| 89 | + exclude: /node_modules/, |
| 90 | + }, |
| 91 | + ], |
| 92 | + }, |
| 93 | + output: { |
| 94 | + path: './', |
| 95 | + filename: 'server.js', |
| 96 | + libraryTarget: 'commonjs2', |
| 97 | + }, |
| 98 | + }, |
| 99 | +} |
0 commit comments