Example #1
0
        loaders: [
            {

                test: /\.jsx?$/,

                include: path.join(__dirname, 'app'),
                loader: "babel-loader",
                exclude: [nodeModulesPath]

            }, {

                test: /\.scss$/,

                include: path.join(__dirname, 'app'),

                loader: ExtractTextPlugin.extract('style-loader', 'css!autoprefixer-loader?browsers=last 2 version!sass')

            }, {
                test: /\.less$/,
                loader: ExtractTextPlugin.extract("style-loader", "css-loader!less-loader")
            },
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract('style-loader', 'postcss-loader')
            },
            {
                test: /\.woff2?$|\.ttf$|\.eot$|\.svg$|\.png|\.jpe?g|\.gif$/,
                loader: 'file-loader'
            }
        ]

module.exports = {
  // entry: "./entry.js",
  entry: {
    styles: "/styles/"
  },
  output: {
    // path: __dirname,
    // filename: "bundle.js"
    filename: "[name].js",
    chunkFile: "[id].js"
  },
  module: {
    loaders: [
      {
        test: /\.scss$/,
        include: /styles/,
        // loader: ExtractTextPlugin.extract("style!css?minimize!autoprefixer?browsers=last 5 versions!sass")
        loader: ExtractTextPlugin.extract("style", "css?minimize", "autoprefixer?browsers=last 3 versions!sass")
      }
    ]
  },
  plugins: [
    new ExtractTextPlugin("[name].css")
  ]
  // sassLoader: {
  //   includePaths: "./"
  // }
}
// whether to generate source map for production files.
// disabling this can speed up the build.
var SOURCE_MAP = false

config.devtool = SOURCE_MAP ? 'source-map' : false

// generate loader string to be used with extract text plugin
function generateExtractLoaders (loaders) {
  return loaders.map(function (loader) {
    return loader + '-loader' + (SOURCE_MAP ? '?sourceMap' : '')
  }).join('!')
}

// http://vuejs.github.io/vue-loader/configurations/extract-css.html
var cssExtractLoaders = {
  css: ExtractTextPlugin.extract('vue-style-loader', generateExtractLoaders(['css']), {publicPath: './'}),
  less: ExtractTextPlugin.extract('vue-style-loader', generateExtractLoaders(['css', 'less'])),
  sass: ExtractTextPlugin.extract('vue-style-loader', generateExtractLoaders(['css', 'sass'])),
  stylus: ExtractTextPlugin.extract('vue-style-loader', generateExtractLoaders(['css', 'stylus']))
}

config.vue = config.vue || {}
config.vue.loaders = config.vue.loaders || {}
Object.keys(cssExtractLoaders).forEach(function (key) {
  config.vue.loaders[key] = cssExtractLoaders[key]
})

config.plugins = (config.plugins || []).concat([
  // http://vuejs.github.io/vue-loader/workflow/production.html
  new webpack.DefinePlugin({
    'process.env': {
Example #4
0
   app: './app',
   todo: './redux_todo',
   counter: './redux_counter'
 },
 output: {
   path: __dirname + '/dist',
   filename: '[name].js',
   publicPath: '/assets/'
 },
 module: {
   loaders: [
     {
       test:   /\.css$/,
       loader: ExtractTextPlugin.extract(
         'style',
         'css?sourceMap',
         'postcss'
       )
     },
     {
       test: /\.scss$/,
       loader: ExtractTextPlugin.extract(
         'style',
         'css!postcss!sass')
     },
     {
       test: /\.(js|jsx)?$/,
       exclude: /(node_modules|bower_components)/,
       loader: 'babel',
       query: {
         presets: ['react', 'es2015']
		path: getPath('./dist'),
		filename: '[name].[chunkhash].bundle.js',
		sourceMapFilename: '[name].[chunkhash].bundle.map'
	},
	module: {
		loaders: [{
				test: /\.js$/,
				exclude: /(node_modules)/,
				loaders: ['babel']
			}, {
				test: /\.html$/,
				loader: 'ngtemplate!html',
				exclude: /(index)/
			}, {
				test: /\.less$/,
				loader: ExtractTextPlugin.extract('style', 'css!less?sourceMap')
			},
			// FONTS
			{
				test: /\.woff$/,
				loader: 'url?limit=100000&name=./fonts/[name]/[hash].[ext]'
			}, {
				test: /\.eot$/,
				loader: 'file'
			}, {
				test: /\.svg$/,
				loader: 'url?limit=100000&name=./fonts/[name]/[hash].[ext]'
			},
			// the url-loader uses DataUrls.
			// the file-loader emits files.
			{
Example #6
0
   filename: "[name].dev.js"
 },
 externals:{
   'jquery':'window.$'
 },
 module: { //使用babel loader
   loaders: [
     {
       test: /\.js$/,
       exclude: /(node_modules|bower_components)/,
       loader: 'babel-loader',
       query: {
         presets: ['es2015']
       }
     },
     {test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' })},
     //{test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader')},
     {test: /\.jpg$/, loader: 'url-loader?limit=100000'},
     { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
     { test: /\.(woff|woff2)$/, loader:"url?prefix=font/&limit=5000" },
     { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream" },
     { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml" },
     {test: require.resolve('jquery'), loader:'expose?jQuery!expose!$'}
   ]
 },
 resolve: {
   alias: {
       'jquery': 'jquery/dist/jquery.min.js',
   }
 },
 plugins: [
Example #7
0
if ( env != 'production' ){
    jshash  = '';
    plugins = [];
    loaders.push(
        { test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/, loader: 'url-loader?limit=50000&name=[path][name].[ext]' },
        { test: /\.css$/, loader: "style!css!postcss" },
        { test: /\.less$/, loader: "style!css!postcss!less" },
        { test: /\.scss$/, loader: "style!css!postcss!sass" },
        { test: /\.html$/, loader: "html" }
    );
}
else{
    loaders.push(
        { test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/, loader: 'url-loader?limit=50000&name=[path][name].[ext]' },
        { test: /\.css$/, loader: ExtractTextPlugin.extract("style", "css!postcss") },
        { test: /\.less$/, loader: ExtractTextPlugin.extract("style", "css!postcss!less") },
        { test: /\.scss$/, loader: ExtractTextPlugin.extract("style", "css!postcss!sass") },
        { test: /\.html$/, loader: "html!html-minify" }
    );

    plugins.push(new HtmlWebpackPlugin({
        filename: options.html.to,
        template: options.html.from,
        inject: true
    }));

    if ( options.css ){
        var ext = '.[contenthash:10].css';
        if ( pkg['project-type'] === 'umd' ){
            ext = '.css';
	bail: true,
	entry: entries,
	devtool: 'source-map', // must be 'source-map' or 'inline-source-map'
	output: {
		path: destDir,
		publicPath: "/",
		filename: "js/[name]-[chunkhash].js",
		chunkFilename: "js/[id]-[chunkhash].js",
		sourceMapFilename: "[file].map"
	},
	recordsOutputPath: path.join(destDir, "records.json"),
	module: {
		loaders: [
			{ test: /\.html$/,   loader: "html?root=.&attrs=link:href img:src" },
			{ test: /\.json$/,   loader: "json" },
			{ test: /\.css$/,    loader: cssExtractPlugin.extract('style', 'css?sourceMap') },
			{ test: /\.less$/,   loader: cssExtractPlugin.extract('style', 'css?sourceMap!less?sourceMap') },
			{ test: /\.(jpe?g|png|gif|svg)$/i,    loader: "file?name=[path][name]-[hash].[ext]!img" },
			{ test: /\.woff$/,   loader: "file?name=[path][name]-[hash].[ext]" },
			{ test: /\.eot$/,    loader: "file?name=[path][name]-[hash].[ext]" },
			{ test: /\.ttf$/,    loader: "file?name=[path][name]-[hash].[ext]" },
		],
		preLoaders: [
			{
				test: /\.js$/,
				include: pathToRegExp(srcDir),
				loader: "jshint"
			}
		]
	},
	plugins: plugins
Example #9
0
 ).forEach((loader) => {
   const [first, ...rest] = loader.loaders
   loader.loader = ExtractTextPlugin.extract(first, rest.join('!'))
   Reflect.deleteProperty(loader, 'loaders')
 })
 },
 DEBUG ?
 {
   test: /\.less$/,
   loaders: [
     'style-loader',
     'css-loader?' + (DEBUG ? 'sourceMap&' : 'minimize&') +
     'localIdentName=[name]_[local]_[hash:base64:3]',
     'postcss-loader',
     'less-loader',
   ],
 } : {
   test: /\.less$/,
   loader: ExtractTextPlugin.extract('style-loader', [
     'css-loader?' + (DEBUG ? 'sourceMap&' : 'minimize&') +
     'localIdentName=[name]_[local]_[hash:base64:3]',
     'postcss-loader',
     'less-loader?compress=false',
   ].join('!')),
 },
 {
   test: /\.scss$/,
   loaders: [
     'isomorphic-style-loader',
     'css-loader?' + (DEBUG ? 'sourceMap&' : 'minimize&') +
     'modules&localIdentName=[name]_[local]_[hash:base64:3]',
     'postcss-loader',
   ],
 }, {
   test: /\.json$/,
   loader: 'json-loader',
 }, {
Example #11
0
    loaders: [
      // js and jsx
      {
        test: /\.jsx?$/i, 
        loader: 'babel',
        include: /src/,
        exclude: /(node_modules|bower_components|dist)/,
        query: {
          presets: ['react', 'es2015', 'stage-2']
        }
      },
      
      // sass
      {
        test: /\.scss$/i,
        loader: ExtractCSS.extract(['css', 'sass'])
      },

      // fonts
      {
        test: /\.woff(\?.*)?$/,
        loader: 'url',
        query: {
          prefix: 'fonts/',
          name: '[path][name].[ext]',
          limit: 10000,
          mimetype: 'application/font-woff'
        }
      },
      {
        test: /\.woff2(\?.*)?$/,
    CleanWebpackPlugin = require( 'clean-webpack-plugin' );

var config = {
    entry: [
        'bootstrap-loader/extractStyles',
        './client/scripts/index.js'
    ],
    output: {
        path: path.join( __dirname, 'public', 'build' ),
        filename: 'bundle.js',
        publicPath: '/build/'
    },

    module: {
        loaders: [
            {test: /\.css$/, loader: ExtractTextPlugin.extract( 'style', 'css!postcss' )},
            {test: /\.scss$/, loader: ExtractTextPlugin.extract( 'style', 'css!postcss!sass' )},
            {test: /\.(woff|woff2|ttf|eot|svg)(\?\S*)?$/, loader: "url?limit=10000"},
            //{test: /bootstrap\/dist\/js\/umd\//, loader: 'imports?jQuery=jquery'},
            {test: /\.hbs$/, loader: 'handlebars?helperDirs[]=' + path.resolve( __dirname, 'shared', 'handlebars' )},
            {test: /\.(png|jpg)$/, loader: 'url?limit=5000'}
        ]
    },

    postcss: [autoprefixer],

    plugins: [
        new ExtractTextPlugin( 'bundle.css', {allChunks: true} ),
        // Bootstrap 4
        //new Webpack.optimize.OccurenceOrderPlugin(),
        //new Webpack.HotModuleReplacementPlugin(),
var config = {
  cache: true,
  entry: {
    index: './client/index.js'
  },
  output: {
    path: 'public/build',
    filename: '[name].js',
    publicPath: '/build/'
  },
  module: {
    loaders: [
      {test: /\.js?/, loader: 'babel', exclude: /(node_modules|lib)/ },
      {test: /\.json$/, loader: 'json' },
      {test: /\.less$/, loader: ExtractTextPlugin.extract('style-loader', 'css!less')},
      {test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css')},
      {test: /\.png$/, loader: 'url?limit=10000&mimetype=image/png'},
      {test: /\.(woff|woff2)$/, loader: 'url?limit=10000&mimetype=application/font-woff'},
      {test: /\.ttf$/, loader: 'url?limit=10000&mimetype=application/octet-stream'},
      {test: /\.(eot|mp3)$/, loader: 'file'},
      {test: /\.svg$/, loader: 'url?limit=10000&mimetype=image/svg+xml'},
      { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff&name=./[hash].[ext]" },
      { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }
    ]
  },
  plugins: [
    // new WebpackCleanupPlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new ExtractTextPlugin('[name].css'),
    new CopyWebpackPlugin([
    loader: "babel-loader"
  },
  {
    test: /\.woff[0-9A-Za-z]*$/,
    loader: require.resolve('file-loader'),
    query: {
      name: 'fonts/[name].[ext]'
    }
  },
  {
    test: /\.json$/,
    loader: "json-loader"
  },
  {
    test: /\.css$/,
    loader: ExtractTextPlugin.extract(options._cssloader)
  },
  {
    test: /\.scss$/,
    loader: ExtractTextPlugin.extract("css-loader!sass-loader!postcss-loader")
  }
]

options.plugins = [
  new webpack.optimize.OccurenceOrderPlugin(),
  new webpack.DefinePlugin({
    '__DEV__': false,
    'process.env': {
      'NODE_ENV': JSON.stringify('production')
    }
  }),
   */
 ], 
 loaders: [
   { test: /jquery\.js$/, loader: 'expose?$' },
   { 
     test: /jquery\..+\.js$/, 
     loader: 'imports?jQuery=jquery,$=jquery,this=>window' 
   },
   { 
     test: /\.js$/, 
     include: [ `${baseDir}/js`, `${baseDir}/lib` ], 
     loader: 'babel-loader' 
   },
   { 
     test: /\.scss$/, 
     loader: ExtractTextPlugin.extract('style', ['css','postcss','sass'].join('!')) 
   },
   { 
     test: /\.css$/, 
     loader: ExtractTextPlugin.extract('style', ['css','postcss'].join('!')) 
   },
   {
     test: /\.(eot|svg|ttf|woff|woff2)/,
     loader: 'file',
     query: {
       name: 'fonts/[name].[ext]'
     }
   },
   {
     test: /\.(png|gif|jpg)/,
     loader: 'file',
Example #16
0
 // separate file in our build process. This way we actually ship
 // a single CSS file in production instead of JS code injecting <style>
 // tags. If you use code splitting, however, any async bundles will still
 // use the "style" loader inside the async code so CSS from them won't be
 // in the main CSS file.
 {
   test: /\.sass$/,
   // "?-autoprefixer" disables autoprefixer in css-loader itself:
   // https://github.com/webpack/css-loader/issues/281
   // We already have it thanks to postcss. We only pass this flag in
   // production because "css" loader only enables autoprefixer-powered
   // removal of unnecessary prefixes when Uglify plugin is enabled.
   // Webpack 1.x uses Uglify plugin as a signal to minify *all* the assets
   // including CSS. This is confusing and will be removed in Webpack 2:
   // https://github.com/webpack/webpack/issues/283
   loader: ExtractTextPlugin.extract('css!sass?indentedSyntax')
   // Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
 },
 // JSON is not enabled by default in Webpack but both Node and Browserify
 // allow it implicitly so we also enable it.
 {
   test: /\.json$/,
   loader: 'json'
 },
 // "file" loader makes sure those assets end up in the `build` folder.
 // When you `import` an asset, you get its filename.
 {
   test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
   loader: 'file',
   query: {
     name: 'static/media/[name].[hash:8].[ext]'
Example #17
0
   main: "./source-src/js/main.js",
   slider: "./source-src/js/slider.js"
 },
 output: {
   path: "./source",
   publicPath: "/",
   filename: "[name].js"
 },
 module: {
   loaders: [{
     test: /\.js$/,
     loader: 'babel',
     exclude: /node_modules/
   }, {
     test: /\.(scss|sass|css)$/,
     loader: ExtractTextPlugin.extract('style-loader', ['css-loader?-autoprefixer', 'postcss-loader', 'sass-loader'])
   }, {
     test: /\.(gif|jpg|png)\??.*$/,
     loader: 'url-loader?limit=500&name=img/[name].[ext]'
   }, {
     test: /\.(woff|svg|eot|ttf)\??.*$/,
     loader: "file-loader?name=fonts/[name].[ext]"
   }]
 },
 alias: {
   'vue$': 'vue/dist/vue.js'
 },
 resolve: {
   alias: {
     'vue$': 'vue/dist/vue.common.js'
   }
Example #18
0
if (TARGET === 'build') {
    module.exports = merge(common, {
        output: {
            path: PATHS.build,
            // Set up caching by adding cache busting hashes to filenames
            // `[chunkhash]` returns a chunk specific hash
            filename: '[name].[chunkhash].js',
            // The filename of non-entry chunks
            chunkFilename: '[chunkhash].js'
        },
        module: {
            loaders: [
                // Extract CSS during build
                {
                    test: /\.(css|scss)$/,
                    loader: ExtractTextPlugin.extract('style', 'css!sass')
                }
            ]
        },
        plugins: [
            // `rm -rf`
            new CleanPlugin([ PATHS.build ]),
            // Setting DefinePlugin affects React library size!
            // DefinePlugin replaces content "as is" so we need some extra
            // quotes for the generated code to make sense
            new webpack.DefinePlugin({
                'process.env': {
                    'NODE_ENV': JSON.stringify('production')
                }
            }),
            // Output extracted CSS to a file
Example #19
0
          }
      },
      {
          test: /\.json(\?v=\d+\.\d+\.\d+)?$/,
          loader: "url",
          query: {
            name: '[name].[ext]?mimetype=application/json'
          }
      }
    ]
  },
  vue: {
        loaders: {
            css: ExtractTextPlugin.extract(
              "style-loader",
              "css-loader?sourceMap",
              {
                publicPath: "../dist/"
              }
            )
        }
  },
  plugins: [
      new ExtractTextPlugin("style.css")
  ],
  babel: {
    presets: ['es2015', 'stage-0'],
    plugins: ['transform-runtime']
  }
}
module.exports = function(options){
    options = options || {}
    var debug = options.debug !==undefined ? options.debug :true;

    var plugins = [];

    var extractCSS;
    var cssLoader;
    var sassLoader;

    plugins.push(new CommonsChunkPlugin({
        name: 'vendor',
        minChunks: Infinity
    }));

    if(debug){
        extractCSS = new ExtractTextPlugin('css/[name].css?[contenthash]')
        cssLoader = extractCSS.extract(['css'])
        sassLoader = extractCSS.extract(['css', 'sass'])

        plugins.push(extractCSS)
    }else{
        extractCSS = new ExtractTextPlugin('css/[contenthash:8].[name].min.css', {
            // 当allChunks指定为false时,css loader必须指定怎么处理
            allChunks: false
        })
        cssLoader = extractCSS.extract(['css?minimize'])
        sassLoader = extractCSS.extract(['css?minimize', 'sass'])

        plugins.push(
            extractCSS,
            new UglifyJsPlugin({
                compress: {
                    warnings: false
                },
                output: {
                    comments: false
                },
                mangle: {
                    except: ['$', 'exports', 'require','avalon']
                }
            }),
            new webpack.optimize.DedupePlugin(),
            new webpack.NoErrorsPlugin()
        )
    }

    //config
    var config = {
        entry: Object.assign(entries(), {
            // 用到什么公共lib(例如jquery.js),就把它加进vendor去,目的是将公用库单独提取打包
            'vendor': ['jquery', 'avalon']
        }),
        output: {
            path: path.join(__dirname, "dist"),
            filename: "js/[name].js",
            chunkFilename: '[chunkhash:8].chunk.js',
            publicPath: publicPath
        },
        module: {
            loaders: [
                {
                    test: /\.((woff2?|svg)(\?v=[0-9]\.[0-9]\.[0-9]))|(woff2?|svg|jpe?g|png|gif|ico)$/,
                    loaders: [
                        //小于10KB的图片会自动转成dataUrl,
                        'url?limit=10000&name=img/[hash:8].[name].[ext]',
                        'image?{bypassOnDebug:true, progressive:true,optimizationLevel:3,pngquant:{quality:"65-80",speed:4}}'
                    ]
                },
                {
                    test: /\.((ttf|eot)(\?v=[0-9]\.[0-9]\.[0-9]))|(ttf|eot)$/,
                    loader: 'url?limit=10000&name=fonts/[hash:8].[name].[ext]'
                },
                {test: /\.(tpl|ejs)$/, loader: 'ejs'},
                {test: /\.css$/, loader: cssLoader},
                {test: /\.scss$/, loader: sassLoader}
            ]
        },
        resolve: {
            extensions: ['', '.js', '.css', '.scss', '.tpl', '.png', '.jpg'],
            root: [srcDir, nodeModPath],
            alias: pathMap,
            publicPath: '/'
        },
        plugins: plugins.concat(html_plugins())
    }

    return config;
}
if(process.env.NODE_ENV !== 'production') {
  lessLoader += '?sourceMap';       //Add LESS sourcemaps
  jsLoaders.push('eslint-loader');  //ESLint loader
}

module.exports = [
  {
    test: /\.jsx?$/,
    exclude: /(node_modules)/,
    loaders: jsLoaders
  },
  {
		test: /\.less$/,
		exclude: /node_modules/,
		loader: ExtractTextPlugin.extract('style-loader', lessLoader, {
      // Tell the less loader to start at `public/` instead of `public/css/` when building relative paths for fonts and images.
      // This lets us use relative paths in our less files and still build our fonts to `public/fonts` and images to `public/images`
      publicPath: '../'
    })
	},
  { test: /\.json$/, loader: 'json-loader' },
  { test: /\.woff$/, loader: 'url?limit=10000&mimetype=application/font-woff&name=fonts/[name].[ext]' },
  { test: /\.woff2$/, loader: 'url?limit=10000&mimetype=application/font-woff2&name=fonts/[name].[ext]' },
  { test: /\.[ot]tf$/, loader: 'url?limit=10000&mimetype=application/octet-stream&name=fonts/[name].[ext]' },
  { test: /\.eot$/, loader: 'url?limit=10000&mimetype=application/vnd.ms-fontobject&name=fonts/[name].[ext]' },
	{ test: /\.svg$/, loader: 'url?limit=10000&mimetype=image/svg+xml&name=images/[name].[ext]' },
  { test: /\.png$/, loader: 'file?mimetype=image/png&name=images/[name].[ext]' },
	{ test: /\.jpe?g$/, loader: 'file?mimetype=image/jpeg&name=images/[name].[ext]' }
];
   'react': 'React',
   'react-dom': 'ReactDOM',
   'react-router': 'ReactRouter',
   'react-redux': 'ReactRedux',
   'antd': 'antd'
 },
 module: {
   loaders: [
     {
       test: /\.jsx?$/,
       exclude: /node_modules/,
       include: includes,
       loader: 'babel-loader'
     }, {
       test: /\.css$/,
       loader: extractStyle.extract(['css', 'postcss'])
     }, {
       test: /\.less$/,
       include: includes,
       loader: extractStyle.extract(['css', 'less', 'postcss'])
     },
     { test: /\.woff2?$/, loader: 'url?limit=10000&minetype=application/font-woff' },
     { test: /\.ttf$/, loader: 'url?limit=10000&minetype=application/octet-stream' },
     { test: /\.eot$/, loader: 'file' },
     { test: /\.svg$/, loader: 'url?limit=10000&minetype=image/svg+xml' },
     { test: /\.(png|jpg|jpeg|gif|webp)$/i, loader: 'url?limit=10000' },
     { test: /\.json$/, loader: 'json' },
     { test: /\.html?$/, loader: 'file?name=[name].[ext]' }
   ]
 },
 resolve: {
  plugins: [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify('production')
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      compressor: {
        warnings: false
      }
    }),
    new ExtractTextPlugin('style.css', { allChunks: true })
  ],
  resolve: {
    extensions: [ '', '.js', '.jsx' ]
  },
  module: {
    loaders: [ {
      test: /\.css$/,
      loader: ExtractTextPlugin.extract('style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader')
    }, {
      test: /\.jsx?$/,
      exclude: /node_modules/,
      loaders: [ 'babel' ],
      include: [path.resolve('./client'), path.resolve('./shared')]
    } ]
  }
};
                 options: {
                     name: '[name].[hash].[ext]',
                 }
             }
         },
         {
             test: /\.css$/,
             use: ['style-loader', 'css-loader']
         },
         {
             test: /\.scss$/,
             use: extractCSSPlugin.extract([
                 {loader: 'css-loader', options: {
                     url: false,
                     sourceMap: true
                 }},
                 {loader: 'sass-loader', options: {
                     sourceMap: true
                 }}
             ])
         }
     ]
 },
 plugins: [
     new ManifestPlugin(),
     new CopyWebpackPlugin([
         // copy-fonts
         {context: 'src/fonts', from: '**/*', to: 'fonts'},
         // copy-images
         {context: 'src/images', from: '**.*', to: 'images'},
         // copy-html-views
  module: {
    preLoaders: [
      { test: /\.ts(x?)$/, loader: "tslint", include: path.resolve(__dirname, "App") },
    ],
    noParse: [],
    loaders: [
      // TODO remove crazy require when https://github.com/babel/babel-loader/issues/166 is fixed.
      {
        test: /\.ts(x?)$/,
        loader: 'babel?cacheDirectory,plugins[]=' + require.resolve(path.join(nodeModulesPath, 'babel-plugin-external-helpers-2')) +
                ',presets[]=' + require.resolve(path.join(nodeModulesPath, 'babel-preset-es2015-loose')) +
                '!ts-loader?configFileName=tsconfig.webpack.json',
        include: path.resolve(__dirname, "App")
      },
      { test: /\.css$/,  loader: ExtractTextPlugin.extract("style-loader", "css-loader?minimize"), include: path.resolve(__dirname, "App") },
      { test: /\.less$/, exclude: /\.module\.less$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader?minimize!less-loader?compress"), include: path.resolve(__dirname, "App") },
      { test: /\.module\.less$/,
        loader: ExtractTextPlugin.extract("style-loader","css-loader?minimize&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!less-loader?-compress"),
        include: path.resolve(__dirname, "App") },
      { test: /\.(jpg|png|woff|eot|ttf|svg|gif)$/, loader: "file-loader?name=[name]_[hash].[ext]", include: path.resolve(__dirname, "App") }
    ]
  },

  plugins: [
    new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors_[chunkhash].js'),
    new ExtractTextPlugin('[name].css', { allChunks: true })
  ],

  tslint: {
    // Rules are in tslint.json
                    plugins: ['transform-runtime'],
                    presets: ['env']
                }
            },

           // JSON loader
            {
                test: /\.json$/,
                exclude: /(node_modules|bower_components)/,
                loader: 'json'
            },
            // CSS Loader
            {
                test: /\.css$/,
                // load css files
                loader: ExtractTextPlugin.extract("style-loader", "css-loader")
            },
        ]
    },
    // resolution
    resolve: {
        extensions: ['.js', '.json', '']
    },

    plugins: [
        // Extract CSS files
        new ExtractTextPlugin("style.css"),
        // Hot module replacement
        new webpack.HotModuleReplacementPlugin()
    ]
};
Example #27
0
	},
	output: {
	    path: __dirname+'/dist/',
		publicPath:'../dist/',
	    //filename: '[name].[chunkhash:8].js'//发布时打开
		filename: '[name].js'
	},
	resolve: {
	    extensions: ['', '.js', '.jsx','.css','.coffee','.es6']
	},
 	module: {
        loaders: [
        	 {test: /(\.jsx|\.js|\.es6)$/, loader: "babel",query: {
		        presets: ['es2015']
		     }}
			,{ test: /\.css$/, loader: ExtractTextPlugin.extract("css-loader?root=..")}
			,{ test: /\.coffee/, loader: 'coffee-loader'}
			,{test: /.(png|jpg)$/, loader: 'url-loader?limit=9000&name=/image/[name].[ext]'}
			,{ test: /\.(woff|woff2|eot|ttf|svg)(\?.*$|$)/, loader: 'url-loader?importLoaders=1&limit=1000&name=fonts/[name].[ext]' }
        ]
    },
    plugins: [
    	//new ExtractTextPlugin("style.[contenthash:9].css"),//发布时打开
		new ExtractTextPlugin("style.css")
		//,new HtmlWebpackPlugin({
		//	template:"./app/index.html"
		//	//path:__dirname+'/dist/'
		//})
		//,new webpack.HotModuleReplacementPlugin()
	]
};
Example #28
0
 module: {
     rules: [
         {
             test: /\.(js|jsx)$/,
             exclude: /(node_modules|bower_components)/,
             use: {
                 loader: 'babel-loader',
                 options: {
                     presets: ['env','react']
                 }
             }
         },
         {
             test: /\.(less|css)$/,
             use: ExtractTextPlugin.extract({
                 fallback: "style-loader",
                 use: ['css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]', 'postcss-loader','less-loader']
             })
         },
         {
             test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
             loader: 'url-loader',
             options: {
                 limit: 10000,
                 name: 'img/[name].[hash:5].[ext]'
             }
         },
         {
             test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
             loader: 'url-loader',
             options: {
                 limit: 10000,
	module: {
		rules: [
			{
				test: /\.js$/,
				loader: 'babel-loader',
				exclude: /node_modules/,
			},
			{
				test: /\.css$/,
				include: /node_modules/,
				loader: ExtractTextPlugin.extract({
					fallback: 'style-loader',
					use: [
						{
							loader: 'css-loader',
							options: {
								modules: false,
								localIdentName: '[name]__[local]___[hash:base64:5]',
							},
						},
					],
				}),
			},
			{
				test: /\.css$/,
				exclude: /node_modules/,
				loader: ExtractTextPlugin.extract({
					fallback: 'style-loader',
					use: [
						{
							loader: 'css-loader',
							options: {
              {
                  test: /\.ts$/, 
                  loader: 'ts', 
                  exclude: /node_modules/
              },
              {
                  test: /\.html$/,
                  loader: 'html'
              },
              {
                  test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
                  loader: 'file?name=assets/[name].[hash].[ext]'
              },
              {
                  test: /\.css$/,
                  exclude: helpers.root('resource', 'app'),
                  loader: ExtractTextPlugin.extract('css', 'css?sourceMap')
              },
              {
                  test: /\.css$/,
                  include: helpers.root('resource', 'app'),
                  loader: 'raw'
              }
          ]
      },
      plugins: [
          new webpack.optimize.CommonsChunkPlugin({
              name: ['bundle']
          })
      ]
};