-
-
Save thewillhuang/d2b5778c572619cb60fce6bcdef5f1af to your computer and use it in GitHub Desktop.
webpack configuration suitable for static content generator plugin and chunks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var ReactDom = require("react-dom"); | |
| var Redux = require("redux"); | |
| var ReactRouter = require("react-router"); | |
| var ReactRedux = require("react-redux"); | |
| var ExtractTextPlugin = require("extract-text-webpack-plugin"); | |
| var window={} | |
| var getElementsByTagName = function (b) { | |
| return [{appendChild:function (c){ | |
| global['webpackJsonp'] = window['webpackJsonp']; | |
| global['React']=React; | |
| console.log(c); | |
| require('./compiled/'+c.src); | |
| }}] | |
| } | |
| var createElement = function (t) {return {}} | |
| var locals = { | |
| paths: [ | |
| '/' | |
| ,'/login' | |
| ,'/about' | |
| ,'/svcs' | |
| ,'/remind' | |
| ,'/register' | |
| ,'/reset' | |
| ], | |
| scope:{ | |
| React:React, | |
| ReactDom:ReactDom, | |
| Redux:Redux, | |
| ReactRedux:ReactRedux, | |
| ReactRouter:ReactRouter | |
| ,window:{} | |
| ,webpackJsonp: function(){} | |
| ,document:{ | |
| getElementsByTagName:getElementsByTagName, | |
| createElement:createElement | |
| } | |
| //documentElement:["classList"]}, | |
| //Element:{prototype:{matches:false}} | |
| } | |
| } | |
| module.exports = { | |
| //node: {process:false}, | |
| entry: {bundle:['./index.js'], main:['./main.js'], style:['./style.scss']}, | |
| output: { | |
| path: __dirname +'/compiled/', | |
| chunkFilename: "[name].js", | |
| filename: '[name].js', | |
| libraryTarget: 'umd' | |
| ,chunkLoadTimeout: 120000 | |
| }, | |
| externals: { "react": "React", "redux": "Redux", "react-dom":"ReactDom", "react-redux":"ReactRedux", "react-router":"ReactRouter"},// "flickity":"Flickity"}, | |
| module: { | |
| loaders: [ | |
| { | |
| test: /\.scss$/, | |
| loader: ExtractTextPlugin.extract("style","css!postcss!sass") | |
| }, | |
| { | |
| test: /.jsx?$/, | |
| loader: 'babel-loader', | |
| exclude: /node_modules/, | |
| query: { | |
| presets: ['react', 'stage-2','es2015-native-modules'], | |
| plugins: ["transform-object-rest-spread","transform-object-assign"] | |
| } | |
| } | |
| ] | |
| }, | |
| resolve: { | |
| extensions: ["", ".js", "jsx", "js6"], | |
| alias: { /*need these for flickity*/ | |
| 'eventEmitter/EventEmitter': 'wolfy87-eventemitter/EventEmitter', | |
| 'get-style-property': 'desandro-get-style-property', | |
| 'matches-selector': 'desandro-matches-selector', | |
| 'classie': 'desandro-classie' | |
| } | |
| }, | |
| plugins: [ | |
| new StaticSiteGeneratorPlugin('main', locals.paths, locals,locals.scope), | |
| new ExtractTextPlugin('css/[name].css', { | |
| allChunks: true | |
| }) | |
| ], | |
| postcss: function () { | |
| return [require('autoprefixer')]; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment