webpack.config.js 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. const webpack = require("webpack");
  2. const path = require('path');
  3. const ExtractTextPlugin = require('extract-text-webpack-plugin');
  4. module.exports = {
  5. entry: {
  6. script: path.resolve(__dirname, 'src', 'index.js'),
  7. },
  8. output: {
  9. path: path.resolve(__dirname, 'public', 'assets'),
  10. filename: '[name].js',
  11. chunkFilename: '[name].js',
  12. publicPath: '/assets/'
  13. },
  14. module: {
  15. rules: [
  16. { test: /\.scss$/, use: ExtractTextPlugin.extract({ fallback: "style-loader", use: ["css-loader", "sass-loader"], publicPath: "/assets" }), exclude: /node_modules/ },
  17. { test: /\.js$/, use: "babel-loader", exclude: /node_modules/ },
  18. { test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff' },
  19. { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=application/octet-stream' },
  20. { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=application/octet-stream' },
  21. { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader' },
  22. ],
  23. },
  24. plugins: [
  25. new ExtractTextPlugin({
  26. filename: "style.css",
  27. disable: false,
  28. allChunks: true
  29. }),
  30. ],
  31. };