Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. "use strict";
  2. const ExtractTextPlugin = require("extract-text-webpack-plugin");
  3. const NODE_ENV = process.env.NODE_ENV || 'development';
  4. const webpack  = require('webpack');
  5. console.log(__dirname);
  6. module.exports = {
  7.     context: __dirname + '/app-frontend/src',
  8.     entry:  {
  9.         create:    './create'
  10.     },
  11.     output: {
  12.         path: __dirname + '/app-frontend/public/js',
  13.         publicPath: '/',
  14.         filename: "[name].js",
  15.         library: '[name]'
  16.     },
  17.     // watch: NODE_ENV   == 'development',
  18.     devtool: NODE_ENV == 'development' ? 'source-map' : null,
  19.  
  20.     plugins : [
  21.         new webpack.NoErrorsPlugin(),
  22.         new webpack.DefinePlugin({
  23.             NODE_ENV: JSON.stringify(NODE_ENV),
  24.             PUBLIC_PATH : JSON.stringify('/public/js')
  25.         }),
  26.         new webpack.optimize.CommonsChunkPlugin({
  27.             name: 'common',
  28.             // chunks: ['ABuilder', 'ADashboard']
  29.             minChunks: 2
  30.         }),
  31.         new ExtractTextPlugin("../css/[name].css")
  32.     ],
  33.     resolve : {
  34.         modulesDirectories: ['node_modules'],
  35.         extensions: ['', '.js']
  36.     },
  37.     resolveLoader : {
  38.         modulesDirectories: ['node_modules'],
  39.         moduleTemplates: ['*-loader', '*'],
  40.         extensions: ['', '.js']
  41.     },
  42.  
  43.     module: {
  44.         loaders: [
  45.             {
  46.                 test: /\.js$/,
  47.                 loader: 'babel-loader',
  48.                 include: __dirname + '/app-frontend',
  49.                 query: {
  50.                     presets: ['es2015', 'react']
  51.                 }
  52.             },
  53.  
  54.             {
  55.                 test: /\.(png|gif|jpg|svg)/,
  56.                 loader: "file-loader?name=[hash].[ext]",
  57.             },
  58.             { test: /\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif)(\?\S*)?$/
  59.                 , loader: 'url?limit=100000&name=[name].[ext]'
  60.             },
  61.             {
  62.                 test: /\.json$/,
  63.                 loaders: ["json-loader"]
  64.             },
  65.             {
  66.                 test: /\.css$/,
  67.                 loader: ExtractTextPlugin.extract("style-loader", "css-loader", "resolve-url-loader"),
  68.                 exclude: /node_modules|tinymce[\\/]skins[\\/]/
  69.             },
  70.             {
  71.                 test: /\.less$/,
  72.                 loader: ExtractTextPlugin.extract("style-loader", "css-loader!resolve-url-loader!less-loader"),
  73.                 exclude: /node_modules/
  74.             }
  75.         ]
  76.     }
  77. }
  78.  
  79. if (NODE_ENV == 'production') {
  80.     module.exports.plugins.push (
  81.         new webpack.optimize.UglifyJsPlugin({
  82.             compress: {
  83.                 warnings: false,
  84.                 drop_console: true,
  85.                 unsafe: true
  86.             }
  87.         })
  88.     );
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement