var webpack = require('webpack'); var commonsPlugin = new
webpack.optimize.CommonsChunkPlugin('common.js'); var ExtractTextPlugin =
require("extract-text-webpack-plugin");
module.exports = {
plugins: [commonsPlugin, new ExtractTextPlugin("[name].css")],
有时候可能希望项目的样式能不要被打包到脚本中,而是独立出来作为.css,然后在页面中以标签引入。这时候我们需要 extract-text-webpack-plugin 来帮忙:
var webpack = require('webpack'); var commonsPlugin = new webpack.optimize.CommonsChunkPlugin('common.js'); var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
plugins: [commonsPlugin, new ExtractTextPlugin("[name].css")],
entry: { //...省略其它配置
最终 webpack 执行后会乖乖地把样式文件提取出来
一周热门 更多>