aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/webpack.dev.js
blob: 4ac420c5c132b50d421225e2d1af55ff5e43593e (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const dartSass = require('sass');
const paths = require('./paths');
require('dotenv').config();

const protocol = process.env.WEBPACK_PROTOCOL;
const host = process.env.WEBPACK_HOST;
const port = process.env.WEBPACK_PORT;
const siteURL = `${protocol}://${host}/`;
const isHttps = protocol === 'https';
const isHMREnabled = process.env.WEBPACK_HOT_RELOAD === 'true';
const isOpenBoolean = process.env.WEBPACK_OPEN === 'true' || process.env.WEBPACK_OPEN === 'false';

module.exports = {
  mode: 'development',
  module: {
    rules: [
      {
        test: /\.(sa|sc|c)ss$/i,
        use: [
          'style-loader',
          {
            loader: 'css-loader',
            options: {
              importLoaders: 2,
              sourceMap: true,
            },
          },
          {
            loader: 'postcss-loader',
            options: {
              postcssOptions: {
                plugins: ['autoprefixer'],
              },
              sourceMap: true,
            },
          },
          {
            loader: 'sass-loader',
            options: {
              implementation: dartSass,
              sassOptions: {
                indentWidth: 2,
                outputStyle: 'expanded',
                includePaths: paths.sassPaths,
              },
              sourceMap: true,
            },
          },
        ],
      },
    ],
  },
  devServer: {
    client: {
      overlay: {
        warnings: true,
        errors: true,
      },
    },
    devMiddleware: {
      writeToDisk: true,
    },
    host,
    port,
    hot: isHMREnabled,
    https: !isHttps
      ? false
      : {
        key: process.env.WEBPACK_HTTPS_KEY,
        cert: process.env.WEBPACK_HTTPS_CERT,
      },
    liveReload: true,
    open: isOpenBoolean
      ? process.env.WEBPACK_OPEN
      : {
        app: {
          name: process.env.WEBPACK_OPEN,
        },
      },
    proxy: {
      '/': {
        target: siteURL,
        changeOrigin: true,
        secure: false,
      },
    },
    static: false,
    watchFiles: paths.files,
  },
  devtool: 'inline-source-map',
};