1 | const path = require( 'path' );
|
2 | const webpack = require( 'webpack' );
|
3 | const HtmlWebpackPlugin = require( 'html-webpack-plugin' );
|
4 | const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
|
5 |
|
6 | module.exports = {
|
7 | mode: 'development',
|
8 |
|
9 | context: path.resolve( __dirname, '..', 'src' ),
|
10 |
|
11 | entry: [ './app/index.js' ],
|
12 |
|
13 | output: {
|
14 | filename: 'bundle.js',
|
15 | path: path.resolve( __dirname, '..', 'dist' ),
|
16 | publicPath: '/'
|
17 | },
|
18 |
|
19 | devServer: {
|
20 | contentBase: path.resolve( __dirname, '..', 'src' ),
|
21 | publicPath: '/',
|
22 | historyApiFallback: true,
|
23 | port: 3000,
|
24 | overlay: {
|
25 | errors: true,
|
26 | warnings: true
|
27 | }
|
28 | },
|
29 |
|
30 | module: {
|
31 | rules: [
|
32 | {
|
33 | test: /\.ejs$/,
|
34 | loader: 'ejs-loader'
|
35 | },
|
36 | {
|
37 | test: /\.html$/,
|
38 | use: [
|
39 | {
|
40 | loader: 'html-loader',
|
41 | options: {
|
42 | minimize: true
|
43 | }
|
44 | }
|
45 | ]
|
46 | },
|
47 | {
|
48 | test: /\.js$/,
|
49 | exclude: /node_modules/,
|
50 | use: [ 'babel-loader' ]
|
51 | },
|
52 | {
|
53 | test: /\.js$/,
|
54 | enforce: 'pre',
|
55 |
|
56 | loader: 'eslint-loader',
|
57 | options: {
|
58 | emitWarning: true
|
59 | }
|
60 | },
|
61 | {
|
62 | test: /\.(scss|css)$/,
|
63 | use: [
|
64 | {
|
65 | loader: 'style-loader'
|
66 | },
|
67 | {
|
68 | loader: 'css-loader'
|
69 | },
|
70 | {
|
71 | loader: 'sass-loader'
|
72 | }
|
73 | ]
|
74 | },
|
75 | {
|
76 | test: /\.svg$/,
|
77 | loader: 'svg-inline-loader'
|
78 | },
|
79 | {
|
80 | test: /\.(jpg|jpeg|png|gif|ico)$/,
|
81 | loader: 'url-loader',
|
82 | query: {
|
83 | limit: 10000,
|
84 | name: 'static/images/[name].[hash].[ext]'
|
85 | }
|
86 | }
|
87 | ]
|
88 | },
|
89 |
|
90 | plugins: [
|
91 | new CopyWebpackPlugin( [
|
92 | {
|
93 | from: './../static',
|
94 | to: 'static'
|
95 | }
|
96 | ] ),
|
97 |
|
98 | new webpack.HotModuleReplacementPlugin(),
|
99 |
|
100 | new webpack.NamedModulesPlugin(),
|
101 |
|
102 | new HtmlWebpackPlugin( {
|
103 | template: path.join( path.resolve( __dirname, '..', 'src' ), 'app/index.ejs' ),
|
104 | path: path.resolve( __dirname, '..', 'dist' ),
|
105 | filename: 'index.html'
|
106 | } )
|
107 | ]
|
108 | };
|