使用webpack将SVG后台文件移动到分发

时间:2018-06-06 16:24:06

标签: reactjs webpack

我正在寻找一种方法来获取所有scss文件和所有背景图片。

这是我当前状态的webpack:

__attribute__((visibility("default")))

我们可以将其设置为引入分发依赖项的文件吗?

以下是我们需要它的示例:

var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
  entry: ['./src/index.tsx', './src/styles/index.scss'],
  output: {
    path: __dirname+'/dist',
    filename: 'bundle.js'
  },
  resolve: {
    extensions: ['.js', '.jsx', '.ts', '.tsx']
  },
  devtool: "source-map",  
  module: {
    rules: [
      {
        test: /\.(ttf|otf|eot|woff(2)?)(\?[a-z0-9]+)?$/, 
        loader: 'file-loader' 
      },
      {
        test: /\.(sass|scss)$/,
        exclude: /node_modules/,
        loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader'])
      },
      {
        test: /\.tsx?$/,
        exclude: /node_modules/,
        loader: "babel-loader?presets[]=es2015&presets[]=react!awesome-typescript-loader"
      },
      {
        test: /\.jsx?/,
        exclude: /node_modules/,
        loader: "babel",
        options: {
          presets: ["es2015", "react"]
        }
      }
    ]
  },
  plugins: [
    new ExtractTextPlugin({
      filename: 'bundle.css',
      allChunks: true,
    })
  ]
};

0 个答案:

没有答案