Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed project webpack config #1606

Merged
merged 1 commit into from
Mar 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions project/prod-webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,24 @@ var LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin");
var ParallelUglifyPlugin = require("webpack-parallel-uglify-plugin");
var DefinePlugin = require("webpack/lib/DefinePlugin");
var NormalModuleReplacementPlugin = require("webpack/lib/NormalModuleReplacementPlugin");
const extractThemesPlugin = require('./MapStore2/themes.js').extractThemesPlugin;
var assign = require('object-assign');
var CopyWebpackPlugin = require('copy-webpack-plugin');

webpackConfig.plugins = [
new CopyWebpackPlugin([
{ from: path.join(__dirname, 'node_modules', 'bootstrap', 'less'), to: path.join(__dirname, "web", "client", "dist", "bootstrap", "less") }
]),
new LoaderOptionsPlugin({
debug: false
debug: false,
options: {
postcss: {
plugins: [
require('postcss-prefix-selector')({prefix: '.__PROJECTNAME__', exclude: ['.__PROJECTNAME__']})
]
},
context: __dirname
}
}),
new DefinePlugin({
"__DEVTOOLS__": false
Expand All @@ -27,7 +41,8 @@ webpackConfig.plugins = [
compress: {warnings: false},
mangle: true
}
})
}),
extractThemesPlugin
];
webpackConfig.devtool = undefined;

Expand Down
96 changes: 84 additions & 12 deletions project/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,36 @@ var DefinePlugin = require("webpack/lib/DefinePlugin");
var LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin");
var NormalModuleReplacementPlugin = require("webpack/lib/NormalModuleReplacementPlugin");
var NoEmitOnErrorsPlugin = require("webpack/lib/NoEmitOnErrorsPlugin");
var CopyWebpackPlugin = require('copy-webpack-plugin');

const assign = require('object-assign');
const themeEntries = require('./MapStore2/themes.js').themeEntries;
const extractThemesPlugin = require('./MapStore2/themes.js').extractThemesPlugin;
module.exports = {
entry: {
entry: assign({
'webpack-dev-server': 'webpack-dev-server/client?http://0.0.0.0:8081', // WebpackDevServer host and port
'webpack': 'webpack/hot/only-dev-server', // "only" prevents reload on syntax errors
'__PROJECTNAME__': path.join(__dirname, "js", "app")
},
}, themeEntries),
output: {
path: path.join(__dirname, "dist"),
publicPath: "/dist/",
filename: "[name].js"
},
plugins: [
new CopyWebpackPlugin([
{ from: path.join(__dirname, 'node_modules', 'bootstrap', 'less'), to: path.join(__dirname, "web", "client", "dist", "bootstrap", "less") }
]),
new LoaderOptionsPlugin({
debug: true
debug: true,
options: {
postcss: {
plugins: [
require('postcss-prefix-selector')({prefix: '.__PROJECTNAME__', exclude: ['.__PROJECTNAME__']})
]
},
context: __dirname
}
}),
new DefinePlugin({
"__DEVTOOLS__": true
Expand All @@ -26,27 +41,84 @@ module.exports = {
new NormalModuleReplacementPlugin(/openlayers$/, path.join(__dirname, "MapStore2", "web", "client", "libs", "openlayers")),
new NormalModuleReplacementPlugin(/cesium$/, path.join(__dirname, "MapStore2", "web", "client", "libs", "cesium")),
new NormalModuleReplacementPlugin(/proj4$/, path.join(__dirname, "MapStore2", "web", "client", "libs", "proj4")),
new NoEmitOnErrorsPlugin()
new NoEmitOnErrorsPlugin(),
extractThemesPlugin
],
resolve: {
extensions: [".js", ".jsx"]
},
module: {
loaders: [
{ test: /\.css$/, loader: 'style-loader!css-loader'},
{ test: /\.less$/, loader: "style-loader!css-loader!less-loader" },
{ test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader?mimetype=application/font-woff" },
{ test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/, loader: "file-loader?name=[name].[ext]" },
{ test: /\.(png|jpg|gif)$/, loader: 'url-loader?name=[path][name].[ext]&limit=8192'}, // inline base64 URLs for <=8k images, direct URLs for the rest
noParse: [/html2canvas/],
rules: [
{
test: /\.css$/,
use: [{
loader: 'style-loader'
}, {
loader: 'css-loader'
}, {
loader: 'postcss-loader'
}]
},
{
test: /\.less$/,
exclude: /themes[\\\/]?.+\.less$/,
use: [{
loader: 'style-loader'
}, {
loader: 'css-loader'
}, {
loader: 'less-loader'
}]
},
{
test: /themes[\\\/]?.+\.less$/,
use: extractThemesPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'postcss-loader', 'less-loader']
})
},
{
test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/,
use: [{
loader: 'url-loader',
options: {
mimetype: "application/font-woff"
}
}]
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9].[0-9].[0-9])?$/,
use: [{
loader: 'file-loader',
options: {
name: "[name].[ext]"
}
}]
},
{
test: /\.(png|jpg|gif)$/,
use: [{
loader: 'url-loader',
options: {
name: "[path][name].[ext]",
limit: 8192
}
}]
},
{
test: /\.jsx?$/,
exclude: /(ol\.js)$|(Cesium\.js)$|(cesium\.js)$/,
loader: "react-hot-loader",
use: [{
loader: "react-hot-loader"
}],
include: [path.join(__dirname, "js"), path.join(__dirname, "MapStore2", "web", "client")]
}, {
test: /\.jsx?$/,
exclude: /(ol\.js)$|(Cesium\.js)$/,
loader: "babel-loader",
use: [{
loader: "babel-loader"
}],
include: [path.join(__dirname, "js"), path.join(__dirname, "MapStore2", "web", "client")]
}
]
Expand Down
7 changes: 1 addition & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ module.exports = {
'webpack-dev-server': 'webpack-dev-server/client?http://0.0.0.0:8081', // WebpackDevServer host and port
'webpack': 'webpack/hot/only-dev-server', // "only" prevents reload on syntax errors
"mapstore2": path.join(__dirname, "web", "client", "product", "app")
}, themeEntries
/* {
"themes/default": path.join(__dirname, "web", "client", "themes", "default", "theme.less"),
"themes/dark": path.join(__dirname, "web", "client", "themes", "dark", "theme.less")
}*/
),
}, themeEntries),
output: {
path: path.join(__dirname, "web", "client", "dist"),
publicPath: "/dist/",
Expand Down