Skip to content

Instantly share code, notes, and snippets.

@z2015
Last active May 2, 2016 02:05
Show Gist options
  • Save z2015/28f814d546382bcec069bb3de15dd322 to your computer and use it in GitHub Desktop.
Save z2015/28f814d546382bcec069bb3de15dd322 to your computer and use it in GitHub Desktop.
处理Webpack提取出来的 css 里面的路径
//http://react-china.org/t/webpack-css/2299
//https://github.com/webpack/extract-text-webpack-plugin
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const definePlugin = new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
})
const sassLoaders = [
'css-loader',
'sass-loader?indentedSyntax=false'
];
const uglifyJsPlugin = new webpack.optimize.UglifyJsPlugin({
output: {
comments: false
},
minimize: true,
compress: {
warnings: false
}
});
module.exports = {
entry:{
loadmore: './src/app/loadmore.js',
single: './src/app/single.js'
},
output: { path: path.join(__dirname, './build'),
filename: 'static/[name].bundle.js'
},
plugins: [
new ExtractTextPlugin('static/zjbd.css'),
definePlugin,
uglifyJsPlugin
],
module: {
loaders: [{
test: /\.js?$/,
loader: 'babel-loader',
excluede: /node_modules/,
query: {
presets: ['es2015']
}
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', sassLoaders.join('!'),{publicPath:'../'})
},
{ test: /\.png$/,
loader: "file-loader?name=img/[name].[ext]"
}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment