]> BookStack Code Mirror - bookstack/blob - webpack.config.js
Attempted move to webpack again
[bookstack] / webpack.config.js
1 const path = require('path');
2 const dev = process.env.NODE_ENV !== 'production';
3
4 const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
5 const ExtractTextPlugin = require("extract-text-webpack-plugin");
6
7 const extractSass = new ExtractTextPlugin({
8     filename: "[name].css"
9     // disable: process.env.NODE_ENV === "development"
10 });
11
12 const config = {
13     entry: {
14         app: './resources/assets/js/index.js',
15         styles: './resources/assets/sass/styles.scss',
16         "export-styles": './resources/assets/sass/export-styles.scss',
17         "print-styles": './resources/assets/sass/print-styles.scss',
18     },
19     output: {
20         filename: '[name].js',
21         path: path.resolve(__dirname, 'public/dist')
22     },
23     module: {
24         rules: [
25             {
26                 test: /\.js$/,
27                 exclude: /(node_modules)/,
28                 use: {
29                     loader: 'babel-loader',
30                     options: {
31                         presets: ['@babel/preset-env']
32                     }
33                 }
34             },
35             {
36                 test: /\.scss$/,
37                 use: extractSass.extract({
38                     use: [{
39                         loader: "css-loader", options: {
40                             sourceMap: dev
41                         }
42                     }, {
43                         loader: "sass-loader", options: {
44                             sourceMap: dev
45                         }
46                     }],
47                     // use style-loader in development
48                     fallback: "style-loader"
49                 })
50             }
51         ]
52     },
53     plugins: [extractSass]
54 };
55
56 if (dev) {
57     config['devtool'] = 'inline-source-map';
58 }
59
60 if (!dev) {
61     config.plugins.push(new UglifyJsPlugin());
62 }
63
64 module.exports = config;