|
| 1 | +const webpack = require('webpack'); |
| 2 | +const path = require('path'); |
| 3 | +const ExtractTextPlugin = require('extract-text-webpack-plugin'); |
| 4 | +const HtmlWebpackPlugin = require('html-webpack-plugin'); |
| 5 | +const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin'); |
| 6 | +const version = require('../package.json').version; |
| 7 | + |
| 8 | +module.exports = function () { |
| 9 | + return { |
| 10 | + devtool: 'cheap-module-source-map', |
| 11 | + entry: { |
| 12 | + main: './src/demo.js' |
| 13 | + }, |
| 14 | + output: { |
| 15 | + path: path.resolve(__dirname, '../demo'), |
| 16 | + filename: `[name].${version}.bundle.js`, |
| 17 | + sourceMapFilename: `[name].${version}.map` |
| 18 | + }, |
| 19 | + module: { |
| 20 | + rules: [ |
| 21 | + { |
| 22 | + enforce: 'pre', |
| 23 | + test: /\.js$/, |
| 24 | + exclude: /node_modules/, |
| 25 | + loader: 'eslint-loader' |
| 26 | + }, |
| 27 | + { |
| 28 | + test: /\.js$/, |
| 29 | + exclude: /node_modules/, |
| 30 | + use: { |
| 31 | + loader: 'babel-loader', |
| 32 | + options: { |
| 33 | + presets: ['env'] |
| 34 | + } |
| 35 | + } |
| 36 | + }, |
| 37 | + { |
| 38 | + test: /\.css$/, |
| 39 | + use: ExtractTextPlugin.extract({ |
| 40 | + fallback: 'style-loader', |
| 41 | + use: 'css-loader' |
| 42 | + }) |
| 43 | + }, |
| 44 | + { |
| 45 | + test: /\.scss$/, |
| 46 | + use: ExtractTextPlugin.extract({ |
| 47 | + fallback: 'style-loader', |
| 48 | + use: [ 'css-loader', 'sass-loader' ] |
| 49 | + }) |
| 50 | + } |
| 51 | + ] |
| 52 | + }, |
| 53 | + plugins: [ |
| 54 | + new ExtractTextPlugin({ |
| 55 | + filename: '[name].bundle.css' |
| 56 | + }), |
| 57 | + new HtmlWebpackPlugin({ |
| 58 | + title: 'SimpleDebugger', |
| 59 | + alwaysWriteToDisk: true |
| 60 | + }), |
| 61 | + new HtmlWebpackHarddiskPlugin(), |
| 62 | + new webpack.NamedModulesPlugin(), |
| 63 | + new webpack.HotModuleReplacementPlugin() |
| 64 | + ], |
| 65 | + devServer: { |
| 66 | + contentBase: './dist', |
| 67 | + port: 7777, |
| 68 | + host: 'localhost', |
| 69 | + hot: true, |
| 70 | + noInfo: false, |
| 71 | + stats: 'minimal' |
| 72 | + } |
| 73 | + }; |
| 74 | +}; |
0 commit comments