私はwebpack
とleaflet
を使用してマップアプリケーションを構築しようとしています。私はmap.js
ファイルからleaflet.js
を要求することができますが、エラーを出さずにleaflet.cssを呼び出すことはできません。webpack - require( 'node_modules/leaflet/leaflet.css')
私の現在のwebpack.config.js
は、次のようになります。
'use strict'
var webpack = require('webpack'),
path = require('path'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
srcPath = path.join(__dirname, 'src');
module.exports = {
target: "web",
cache: true,
entry: {
app: path.join(srcPath, "index.js")
},
resolve: {
alais: {
leaflet_css: __dirname + "/node_modules/leaflet/dist/leaflet.css"
}
},
module: {
loaders: [
{test: /\.js?$/, exclude: /node_modules/, loader: "babel-loader"},
{test: /\.scss?$/, exclude: /node_modules/, loader: "style!css!sass!"},
{test: /\.css?$/, loader: "style!css!"}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin("common", "common.js"),
new HtmlWebpackPlugin({
inject: true,
template: "src/index.html"
}),
new webpack.NoErrorsPlugin()
],
output: {
path: path.join(__dirname, "dist"),
publicPath: "/dist/",
filename: "[name].js",
pathInfo: true
}
}
そして、私のmain.js
ファイルは次のようになります。
var $ = require('jquery'),
leaflet = require('leaflet');
require("./sass/main.scss");
require("leaflet_css");
var map = L.map('map').setView([51.505, -0.09], 13);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.marker([51.5, -0.09]).addTo(map)
.bindPopup('A pretty CSS3 popup.<br> Easily customizable.')
.openPopup();
console.log('I got called');
WebPACKを介して、サードパーティのサプライヤーからのcssファイルを束ねるの正しいアプローチは何ですか?
私はこの理由は、それがnpm
経由node_modules
direcoryにインストールされている場合、なぜlibs
ディレクトリに保存するものだ... this projectはleaflet
はlibsディレクトリに格納された見ましたか?
これは非常に学習の練習ですので、どんな指針も大変ありがとうございます! :)
可能な重複PNG形式のためのローダーを追加するために必要な[WebPACKのを使用してノードの\ _modulesから静的なCSSファイルをロードする方法の例を?](http://stackoverflow.com/questions/34311656/exampleノードモジュールからWebpackを使用してロードする静的CSSファイルの例) – Drew
@Drew - この質問は以前に投稿されました - あなたの例は重複しています。残念ながら、私はそのようにするための十分なアクセス権がありません。 – hloughrey