]> BookStack Code Mirror - bookstack/blob - webpack.config.js
Fixes a corner case with exclamation in the ID.
[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 config = {
8     target: 'web',
9     mode: dev? 'development' : 'production',
10     entry: {
11         app: './resources/assets/js/index.js',
12         styles: './resources/assets/sass/styles.scss',
13         "export-styles": './resources/assets/sass/export-styles.scss',
14         "print-styles": './resources/assets/sass/print-styles.scss',
15     },
16     output: {
17         filename: '[name].js',
18         path: path.resolve(__dirname, 'public/dist')
19     },
20     module: {
21         rules: [
22             {
23                 test: /\.js$/,
24                 exclude: /(node_modules)/,
25                 use: {
26                     loader: 'babel-loader',
27                     options: {
28                         presets: ['@babel/preset-env']
29                     }
30                 }
31             },
32             {
33                 test: /\.scss$/,
34                 use: ExtractTextPlugin.extract({
35                     fallback: "style-loader",
36                     use: [{
37                         loader: "css-loader", options: {
38                             sourceMap: dev
39                         }
40                     }, {
41                         loader: 'postcss-loader',
42                         options: {
43                             ident: 'postcss',
44                             sourceMap: dev,
45                             plugins: (loader) => [
46                                 require('autoprefixer')(),
47                             ]
48                         }
49                     }, {
50                         loader: "sass-loader", options: {
51                             sourceMap: dev
52                         }
53                     }]
54                 })
55             }
56         ]
57     },
58     plugins: [
59         new ExtractTextPlugin("[name].css"),
60     ]
61 };
62
63 if (dev) {
64     config['devtool'] = 'inline-source-map';
65 }
66
67 if (!dev) {
68     config.plugins.push(new UglifyJsPlugin());
69 }
70
71 module.exports = config;
Morty Proxy This is a proxified and sanitized view of the page, visit original site.