frontend_app_folder_advanced/webpack.config.js   A
last analyzed

Complexity

Total Complexity 6
Complexity/F 0

Size

Lines of Code 87
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
wmc 6
eloc 60
nc 64
mnd 1
bc 0
fnc 0
dl 0
loc 87
bpm 0
cpm 0
noi 1
c 0
b 0
f 0
rs 10
1
const webpack = require('webpack')
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2
const path = require('path')
3
const isProduction = process.env.NODE_ENV === 'production'
4
5
console.log('isProduction : ', isProduction)
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
6
7
module.exports = {
8
  entry: isProduction
9
    ? './src/index.js' // only one instance of babel-polyfill is allowed
10
    : ['babel-polyfill', './src/index.dev.js'],
11
  output: {
12
    path: path.resolve(__dirname, 'dist'),
13
    filename: isProduction ? 'folder.app.js' : 'folder.app.dev.js',
14
    pathinfo: !isProduction,
15
    library: isProduction ? 'appFolder' : undefined,
16
    libraryTarget: isProduction ? 'var' : undefined
17
  },
18
  externals: {},
19
  // isProduction ? { // Côme - since plugins are imported through <script>, cannot externalize libraries
20
  //   react: {commonjs: 'react', commonjs2: 'react', amd: 'react', root: '_'},
21
  //   'react-dom': {commonjs: 'react-dom', commonjs2: 'react-dom', amd: 'react-dom', root: '_'},
22
  //   classnames: {commonjs: 'classnames', commonjs2: 'classnames', amd: 'classnames', root: '_'},
23
  //   'prop-types': {commonjs: 'prop-types', commonjs2: 'prop-types', amd: 'prop-types', root: '_'},
24
  //   tracim_lib: {commonjs: 'tracim_lib', commonjs2: 'tracim_lib', amd: 'tracim_lib', root: '_'}
25
  // }
26
  // : {},
27
  devServer: {
28
    contentBase: path.join(__dirname, 'dist/'),
29
    port: 8074,
30
    hot: true,
31
    noInfo: true,
32
    overlay: {
33
      warnings: false,
34
      errors: true
35
    },
36
    historyApiFallback: true
37
    // headers: {
38
    //   'Access-Control-Allow-Origin': '*'
39
    // }
40
  },
41
  devtool: isProduction ? false : 'cheap-module-source-map',
42
  module: {
43
    rules: [{
44
      test: /\.jsx?$/,
45
      enforce: 'pre',
46
      use: 'standard-loader',
47
      exclude: [/node_modules/]
48
    }, {
49
      test: [/\.js$/, /\.jsx$/],
50
      loader: 'babel-loader',
51
      options: {
52
        presets: ['env', 'react'],
53
        plugins: ['transform-object-rest-spread', 'transform-class-properties', 'transform-object-assign']
54
      },
55
      exclude: [/node_modules/]
56
    }, {
57
      test: /\.css$/,
58
      use: ['style-loader', 'css-loader']
59
    }, {
60
      test: /\.styl$/,
61
      use: ['style-loader', 'css-loader', 'stylus-loader']
62
    }, {
63
      test: /\.(jpg|png|svg)$/,
64
      loader: 'url-loader',
65
      options: {
66
        limit: 25000
67
      }
68
    }]
69
  },
70
  resolve: {
71
    extensions: ['.js', '.jsx']
72
  },
73
  plugins: [
74
    ...[], // generic plugins always present
75
    ...(isProduction
76
      ? [ // production specific plugins
77
        new webpack.DefinePlugin({
78
          'process.env': { 'NODE_ENV': JSON.stringify('production') }
79
        }),
80
        new webpack.optimize.UglifyJsPlugin({
81
          compress: { warnings: false }
82
        })
83
      ]
84
      : [] // development specific plugins
85
    )
86
  ]
87
}
88