-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
57 lines (53 loc) · 1.56 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const WebpackShellPlugin = require('webpack-shell-plugin');
const config = {
entry: {
app: './src/js/index.js'
},
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: '[name].bundle.js'
},
devServer: {
historyApiFallback: {
rewrites: [{"from": "/how", "to": "/how.html"},{"from": "/index", "to": "/index.html"},{"from": "/now", "to": "/now.html"},{"from": "/why", "to": "/why.html"}]
},
contentBase: './dist'
},
devtool: 'cheap-module-source-map',
module: {
rules: [{
test: /\.js$/,
loader: 'babel-loader', // use the loader “babel-loader” to transform those files
exclude: /node_modules/, // Do not fetch the packages installed by NPM
query: {
presets: ['es2015']
}
},
{
test: /\.scss$/,
use: [
{loader: 'style-loader'},
{loader: 'css-loader'},
{loader: 'postcss-loader'},
{loader: 'sass-loader'},
]
}]
},
plugins: [
new CopyWebpackPlugin([
{from: './assets', to: 'assets'}
]),
//new ExtractTextPlugin('assets/css/[name].[contenthash].css'),
new ManifestPlugin()
]
};
if (process.env.NODE_ENV !== 'production') {
config.plugins.push(new WebpackShellPlugin({onBuildEnd: ['yarn mustache:watch']}));
}
module.exports = config;