move assets found in node_modules/ to dist/vendor; simpler assets/config.json (#1697)
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"context": "assets",
|
|
||||||
"entry": {
|
"entry": {
|
||||||
"main": [
|
"main": [
|
||||||
"./scripts/main.js",
|
"./scripts/main.js",
|
||||||
@@ -9,10 +8,6 @@
|
|||||||
"./scripts/customizer.js"
|
"./scripts/customizer.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"output": {
|
"publicPath": "/app/themes/sage",
|
||||||
"path": "dist",
|
"devUrl": "http://example.dev"
|
||||||
"publicPath": "/app/themes/sage/dist/"
|
|
||||||
},
|
|
||||||
"devUrl": "http://example.dev",
|
|
||||||
"devPort": 3000
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ var config = require('./assets/config');
|
|||||||
var scriptsFilename = (argv.release) ? 'scripts/[name]_[hash].js' : 'scripts/[name].js',
|
var scriptsFilename = (argv.release) ? 'scripts/[name]_[hash].js' : 'scripts/[name].js',
|
||||||
stylesFilename = (argv.release) ? 'styles/[name]_[hash].css' : 'styles/[name].css',
|
stylesFilename = (argv.release) ? 'styles/[name]_[hash].css' : 'styles/[name].css',
|
||||||
sourceMapQueryStr = (argv.release) ? '-sourceMap' : '+sourceMap',
|
sourceMapQueryStr = (argv.release) ? '-sourceMap' : '+sourceMap',
|
||||||
|
assets = 'assets/',
|
||||||
|
dist = 'dist/',
|
||||||
jsLoader,
|
jsLoader,
|
||||||
webpackConfig;
|
webpackConfig;
|
||||||
|
|
||||||
@@ -83,18 +85,18 @@ var addHotMiddleware = function (entry) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
webpackConfig = {
|
webpackConfig = {
|
||||||
context: path.resolve(config.context),
|
context: path.resolve(assets),
|
||||||
entry: config.entry,
|
entry: config.entry,
|
||||||
output: {
|
output: {
|
||||||
path: path.join(__dirname, config.output.path),
|
path: path.join(__dirname, dist),
|
||||||
publicPath: config.output.publicPath,
|
publicPath: path.join(config.publicPath, dist),
|
||||||
filename: scriptsFilename
|
filename: scriptsFilename
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
preLoaders: [
|
preLoaders: [
|
||||||
{
|
{
|
||||||
test: /\.js?$/,
|
test: /\.js?$/,
|
||||||
include: path.resolve('assets'),
|
include: path.resolve(assets),
|
||||||
loader: 'eslint'
|
loader: 'eslint'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -102,6 +104,7 @@ webpackConfig = {
|
|||||||
jsLoader,
|
jsLoader,
|
||||||
{
|
{
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
|
include: path.resolve(assets),
|
||||||
loader: ExtractTextPlugin.extract('style', [
|
loader: ExtractTextPlugin.extract('style', [
|
||||||
'css?' + sourceMapQueryStr,
|
'css?' + sourceMapQueryStr,
|
||||||
'postcss'
|
'postcss'
|
||||||
@@ -109,6 +112,7 @@ webpackConfig = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.scss$/,
|
test: /\.scss$/,
|
||||||
|
include: path.resolve(assets),
|
||||||
loader: ExtractTextPlugin.extract('style', [
|
loader: ExtractTextPlugin.extract('style', [
|
||||||
'css?' + sourceMapQueryStr,
|
'css?' + sourceMapQueryStr,
|
||||||
'postcss',
|
'postcss',
|
||||||
@@ -117,13 +121,14 @@ webpackConfig = {
|
|||||||
])
|
])
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(png|jpg|jpeg|gif)(\?.*)?$/,
|
test: /\.(png|jpg|jpeg|gif|svg)(\?.*)?$/,
|
||||||
|
include: path.resolve(assets),
|
||||||
loaders: [
|
loaders: [
|
||||||
'file?' + qs.stringify({
|
'file?' + qs.stringify({
|
||||||
name: 'images/[name]_[md5:hash:hex:8].[ext]'
|
name: '[path][name].[ext]'
|
||||||
}),
|
}),
|
||||||
'image-webpack?' + JSON.stringify({
|
'image-webpack?' + JSON.stringify({
|
||||||
bypassOnDebug:true,
|
bypassOnDebug: true,
|
||||||
progressive: true,
|
progressive: true,
|
||||||
optimizationLevel: 7,
|
optimizationLevel: 7,
|
||||||
interlaced: true,
|
interlaced: true,
|
||||||
@@ -139,17 +144,27 @@ webpackConfig = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(ttf|eot|svg)(\?.*)?$/,
|
test: /\.(ttf|eot)(\?.*)?$/,
|
||||||
|
include: path.resolve(assets),
|
||||||
loader: 'file?' + qs.stringify({
|
loader: 'file?' + qs.stringify({
|
||||||
name: 'fonts/[name]_[md5:hash:hex:8].[ext]'
|
name: '[path][name]_[md5:hash:hex:8].[ext]'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.woff(2)?(\?.*)?$/,
|
test: /\.woff(2)?(\?.*)?$/,
|
||||||
|
include: path.resolve(assets),
|
||||||
loader: 'url?' + qs.stringify({
|
loader: 'url?' + qs.stringify({
|
||||||
limit: 10000,
|
limit: 10000,
|
||||||
mimetype: "application/font-woff",
|
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]'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -165,7 +180,7 @@ webpackConfig = {
|
|||||||
jquery: 'jQuery'
|
jquery: 'jQuery'
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new Clean([config.output.path]),
|
new Clean([dist]),
|
||||||
new ExtractTextPlugin(stylesFilename, {
|
new ExtractTextPlugin(stylesFilename, {
|
||||||
allChunks: true,
|
allChunks: true,
|
||||||
disable: (argv.watch === true) // '--watch' disable ExtractTextPlugin
|
disable: (argv.watch === true) // '--watch' disable ExtractTextPlugin
|
||||||
@@ -210,7 +225,7 @@ if (argv.watch) {
|
|||||||
// '--release' to push additional plugins to webpackConfig
|
// '--release' to push additional plugins to webpackConfig
|
||||||
if (argv.release) {
|
if (argv.release) {
|
||||||
webpackConfig.plugins.push(new AssetsPlugin({
|
webpackConfig.plugins.push(new AssetsPlugin({
|
||||||
path: path.join(__dirname, config.output.path),
|
path: path.join(__dirname, dist),
|
||||||
filename: 'assets.json',
|
filename: 'assets.json',
|
||||||
fullPath: false,
|
fullPath: false,
|
||||||
processOutput: assetsPluginProcessOutput
|
processOutput: assetsPluginProcessOutput
|
||||||
|
|||||||
Reference in New Issue
Block a user