Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/sage-9' into sage-9-public-path
Browse files Browse the repository at this point in the history
* upstream/sage-9:
  move assets found in node_modules/ to dist/vendor; simpler assets/config.json (roots#1697)

# Conflicts:
#	assets/config.json
  • Loading branch information
Patrick Vézina committed Aug 26, 2016
2 parents d4256ae + 97c1a30 commit 33578d0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
6 changes: 1 addition & 5 deletions assets/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"context": "assets",
"entry": {
"main": [
"./scripts/util/public-path.js",
Expand All @@ -10,9 +9,6 @@
"./scripts/customizer.js"
]
},
"output": {
"path": "dist",
"publicPath": "/app/themes/sage/dist/"
},
"publicPath": "/app/themes/sage",
"devUrl": "http://example.dev"
}
39 changes: 27 additions & 12 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ var config = require('./assets/config');
var scriptsFilename = (argv.release) ? 'scripts/[name]_[hash].js' : 'scripts/[name].js',
stylesFilename = (argv.release) ? 'styles/[name]_[hash].css' : 'styles/[name].css',
sourceMapQueryStr = (argv.release) ? '-sourceMap' : '+sourceMap',
assets = 'assets/',
dist = 'dist/',
jsLoader,
webpackConfig;

Expand Down Expand Up @@ -83,32 +85,34 @@ var addHotMiddleware = function (entry) {
};

webpackConfig = {
context: path.resolve(config.context),
context: path.resolve(assets),
entry: config.entry,
output: {
path: path.join(__dirname, config.output.path),
publicPath: config.output.publicPath,
path: path.join(__dirname, dist),
publicPath: path.join(config.publicPath, dist),
filename: scriptsFilename
},
module: {
preLoaders: [
{
test: /\.js?$/,
include: path.resolve('assets'),
include: path.resolve(assets),
loader: 'eslint'
}
],
loaders: [
jsLoader,
{
test: /\.css$/,
include: path.resolve(assets),
loader: ExtractTextPlugin.extract('style', [
'css?' + sourceMapQueryStr,
'postcss'
])
},
{
test: /\.scss$/,
include: path.resolve(assets),
loader: ExtractTextPlugin.extract('style', [
'css?' + sourceMapQueryStr,
'postcss',
Expand All @@ -117,13 +121,14 @@ webpackConfig = {
])
},
{
test: /\.(png|jpg|jpeg|gif)(\?.*)?$/,
test: /\.(png|jpg|jpeg|gif|svg)(\?.*)?$/,
include: path.resolve(assets),
loaders: [
'file?' + qs.stringify({
name: 'images/[name]_[md5:hash:hex:8].[ext]'
name: '[path][name].[ext]'
}),
'image-webpack?' + JSON.stringify({
bypassOnDebug:true,
bypassOnDebug: true,
progressive: true,
optimizationLevel: 7,
interlaced: true,
Expand All @@ -139,17 +144,27 @@ webpackConfig = {
]
},
{
test: /\.(ttf|eot|svg)(\?.*)?$/,
test: /\.(ttf|eot)(\?.*)?$/,
include: path.resolve(assets),
loader: 'file?' + qs.stringify({
name: 'fonts/[name]_[md5:hash:hex:8].[ext]'
name: '[path][name]_[md5:hash:hex:8].[ext]'
})
},
{
test: /\.woff(2)?(\?.*)?$/,
include: path.resolve(assets),
loader: 'url?' + qs.stringify({
limit: 10000,
mimetype: "application/font-woff",
name: "fonts/[name]_[md5:hash:hex:8].[ext]"
name: "[path][name]_[md5:hash:hex:8].[ext]"
})
},
// Use file-loader for node_modules/ assets
{
test: /\.(ttf|eot|woff(2)?|png|jpg|jpeg|gif|svg)(\?.*)?$/,
include: /node_modules/,
loader: 'file?' + qs.stringify({
name: 'vendor/[name]_[md5:hash:hex:8].[ext]'
})
}
]
Expand All @@ -165,7 +180,7 @@ webpackConfig = {
jquery: 'jQuery'
},
plugins: [
new Clean([config.output.path]),
new Clean([dist]),
new ExtractTextPlugin(stylesFilename, {
allChunks: true,
disable: (argv.watch === true) // '--watch' disable ExtractTextPlugin
Expand Down Expand Up @@ -213,7 +228,7 @@ if (argv.watch) {
// '--release' to push additional plugins to webpackConfig
if (argv.release) {
webpackConfig.plugins.push(new AssetsPlugin({
path: path.join(__dirname, config.output.path),
path: path.join(__dirname, dist),
filename: 'assets.json',
fullPath: false,
processOutput: assetsPluginProcessOutput
Expand Down

0 comments on commit 33578d0

Please sign in to comment.