Skip to content

Instantly share code, notes, and snippets.

@lizzie
Created April 20, 2015 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizzie/e9232d8bcec793c7bf52 to your computer and use it in GitHub Desktop.
Save lizzie/e9232d8bcec793c7bf52 to your computer and use it in GitHub Desktop.
webpack加载spm组件的配置
var webpack = require('webpack');
var path = require('path');
var bower_dir = path.join(__dirname, 'bower_components');
var node_modules_dir = path.join(__dirname, 'node_modules');
var spm_dir = path.join(__dirname, 'spm_modules');
var config = {
addVendor: function (name, path) {
this.resolve.alias[name] = path;
this.module.noParse.push(path);
},
context: __dirname,
entry: {
app: ['webpack/hot/dev-server', './app/main.js']
},
output: {
publicPath: '/',
path: path.resolve(__dirname, process.env.NODE_ENV === 'production' ? './dist/' : './build'),
filename: 'bundle.js'
},
resolve: {
alias: {}
},
module: {
noParse: [],
loaders: [{
test: /\.js$/,
loader: 'jsx-loader',
exclude: [bower_dir, node_modules_dir]
}, {
test: /\.css$/,
loader: 'style-loader!css-loader'
}, {
test: /\.(woff|png)$/,
loader: 'url-loader?limit=100000'
}]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin('app', null, false)
]
};
config.addVendor('react', path.resolve(bower_dir, 'react/react.min.js'));
config.addVendor('arale-base', path.resolve(spm_dir, 'arale-base/1.2.0/base.js'));
config.addVendor('arale-class', path.resolve(spm_dir, 'arale-class/1.2.0/class.js'));
config.addVendor('arale-events', path.resolve(spm_dir, 'arale-events/1.2.0/events.js'));
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment