UNPKG

2.31 kBJavaScriptView Raw
1"use strict";
2
3const webpack = require('webpack');
4const ExtractTextPlugin = require('extract-text-webpack-plugin');
5const autoprefixer = require('autoprefixer');
6const environment = process.env.NODE_ENV || 'development';
7
8const config = {
9 name: 'js',
10 entry: {
11 app: './public/js/index.js'
12 },
13 output: {
14 path: __dirname + "/public/build",
15 filename: 'build.[name].js',
16 publicPath: './build'
17 },
18 module: {
19 rules: [
20 {
21 use: 'babel-loader',
22 test: /\.js?$/,
23 exclude: /node_modules/
24 },
25 {
26 use: [ 'style-loader', 'css-loader' ],
27 test: /\.css?$/,
28 exclude: /node_modules/
29 },
30 {
31 test: /\.pug?$/,
32 use: [
33 "file-loader?name=../../[name].html",
34 "extract-loader",
35 "html-loader",
36 "pug-html-loader"
37 ],
38 exclude: /node_modules/
39 },
40 {
41 test: /\.styl$/,
42 loader: ExtractTextPlugin.extract({ fallback: 'style-loader',
43 use: [
44 'css-loader?minimize!',
45 {
46 loader: 'postcss-loader',
47 options: {
48 plugins: function () {
49 return [autoprefixer()]
50 },
51 sourceMap: 'inline'
52 }
53 },
54 'stylus-loader'
55 ]
56 })
57 },
58 {
59 test: /\.(png|woff|woff2|otf|eot|ttf|svg|jpg|jpeg)$/,
60 loader: 'file-loader?limit=100000'
61 }
62 ]
63 },
64 performance: { hints: false },
65 optimization: {},
66 mode: environment,
67 plugins: [
68 new ExtractTextPlugin("build.[name].css") ]
69};
70
71if (environment === 'production') {
72 config.optimization.minimize = true;
73 babelSettings.plugins.push("transform-react-inline-elements");
74 babelSettings.plugins.push("transform-react-constant-elements");
75}
76
77
78module.exports = config;
\No newline at end of file